提出 #36726288


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,n) for (int i=a;i<(int)n;i++)
int read(){int r;scanf("%d",&r);return r;}

void o(int st,int len){
  printf("%d %d\n",st,len);
  fflush(stdout);
}

void o(const char *s){
  printf("%s\n",s);
  fflush(stdout);
}

int n,l,r;

void Grundy() {
  vector<int> dp(n+1); // dp[0..n] = 0 Grundy's number
  rep(i,1,n+1) { // 枚举长度
    vector<bool> s(i+1); // s[0..i] = 0
    rep(j,0,i-l+1) s[dp[j]^dp[i-l-j]] = true; // 计算它的所有拆分的 xor
    while (s[dp[i]]) dp[i]++; // mex
  }
  vector<int> a(n,1); // [0...n) = 1, [n] = 0, 0-index 表示 剩余的点
  a.push_back(0);
  auto fil = [&](int x, int y) { fill(&a[x],&a[x+y],0); }; // a[x..x+y-1] = 0
  auto f = [&]() {
    vector<pair<int,int> > ls; // {len, start idx}
    int now = 0; // 当前连续的长度
    int x = 0; // 所有连续段 的 grundy xor
    int si = 0; // 起始的位置
    rep(i,0,n+1) {
      if (a[i]) { // 为1
        ++now;
      }else { // 为 0
        if (now) {
          ls.push_back({now,si});
          x ^= dp[now];
        }
        now = 0;
        si = i+1;
      }
    }
    for (auto [w,si]: ls) rep(j,0,w-l+1) if((x^dp[w]^dp[j]^dp[w-l-j]) == 0){// 枚举位置 一定存在一个方案 成立
      o(si+j+1,l);
      fil(si+j,l);
      return;
    }
  };
  if (dp[n]) {
    o("First");
    f();
  } else {
    o("Second");
  }
  while (1) {
    int x=read();
    int y=read();
    if (x <= 0) break;
    fil(x-1,y);
    f();
  }
}

int main() {
  n=read();
  l=read();
  r=read();
  if (l == r) {
    Grundy();
  } else { // 对称就完事
    o("First");
    for(int w:{l,l+1}) if ((n-w)%2 == 0) {
      int i = (n-w)/2+1; // [1..i-1][i...i+w-1][i+w..n]
      o(i,w);
      i += w-1; // [1..i-1] 与 [i+w..n] 的偏移量
      while (1) {
        int x=read();
        int y=read();
        if (x <= 0) break;
        x += (x<i)?i:-i;
        o(x,y);
      }
      break;
    }
  }
  return 0;
}

提出情報

提出日時
問題 G - Generalized Subtraction Game
ユーザ cromarmot
言語 C++ (GCC 9.2.1)
得点 600
コード長 2061 Byte
結果 AC
実行時間 54 ms
メモリ 35480 KiB

コンパイルエラー

./Main.cpp: In function ‘int read()’:
./Main.cpp:5:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    5 | int read(){int r;scanf("%d",&r);return r;}
      |                  ~~~~~^~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 1
AC × 58
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_l_eq_r_00.txt, 01_l_eq_r_01.txt, 01_l_eq_r_02.txt, 01_l_eq_r_03.txt, 01_l_eq_r_04.txt, 02_l_eq_r_first_00.txt, 02_l_eq_r_first_01.txt, 02_l_eq_r_first_02.txt, 02_l_eq_r_first_03.txt, 02_l_eq_r_first_04.txt, 03_l_eq_r_second_00.txt, 03_l_eq_r_second_01.txt, 03_l_eq_r_second_02.txt, 03_l_eq_r_second_03.txt, 03_l_eq_r_second_04.txt, 03_l_eq_r_second_05.txt, 03_l_eq_r_second_06.txt, 03_l_eq_r_second_07.txt, 03_l_eq_r_second_08.txt, 03_l_eq_r_second_09.txt, 03_l_eq_r_second_10.txt, 03_l_eq_r_second_11.txt, 03_l_eq_r_second_12.txt, 03_l_eq_r_second_13.txt, 03_l_eq_r_second_14.txt, 03_l_eq_r_second_15.txt, 04_random_00.txt, 04_random_01.txt, 04_random_02.txt, 04_random_03.txt, 04_random_04.txt, 04_random_05.txt, 04_random_06.txt, 04_random_07.txt, 04_random_08.txt, 04_random_09.txt, 05_l_plus_1_eq_r_00.txt, 05_l_plus_1_eq_r_01.txt, 05_l_plus_1_eq_r_02.txt, 06_l_plus_2_eq_r_00.txt, 06_l_plus_2_eq_r_01.txt, 06_l_plus_2_eq_r_02.txt, 07_r_small_00.txt, 07_r_small_01.txt, 07_r_small_02.txt, 07_r_small_03.txt, 07_r_small_04.txt, 07_r_small_05.txt, 07_r_small_06.txt, 07_r_small_07.txt, 07_r_small_08.txt, 07_r_small_09.txt, 07_r_small_10.txt, 07_r_small_11.txt, 07_r_small_12.txt, 07_r_small_13.txt, 07_r_small_14.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 37 ms 35400 KiB
01_l_eq_r_00.txt AC 29 ms 35344 KiB
01_l_eq_r_01.txt AC 34 ms 35344 KiB
01_l_eq_r_02.txt AC 33 ms 35448 KiB
01_l_eq_r_03.txt AC 35 ms 35416 KiB
01_l_eq_r_04.txt AC 30 ms 35440 KiB
02_l_eq_r_first_00.txt AC 36 ms 35452 KiB
02_l_eq_r_first_01.txt AC 38 ms 35472 KiB
02_l_eq_r_first_02.txt AC 36 ms 35392 KiB
02_l_eq_r_first_03.txt AC 33 ms 35396 KiB
02_l_eq_r_first_04.txt AC 35 ms 35432 KiB
03_l_eq_r_second_00.txt AC 41 ms 35364 KiB
03_l_eq_r_second_01.txt AC 40 ms 35404 KiB
03_l_eq_r_second_02.txt AC 34 ms 35304 KiB
03_l_eq_r_second_03.txt AC 36 ms 35384 KiB
03_l_eq_r_second_04.txt AC 31 ms 35368 KiB
03_l_eq_r_second_05.txt AC 35 ms 35360 KiB
03_l_eq_r_second_06.txt AC 53 ms 35388 KiB
03_l_eq_r_second_07.txt AC 47 ms 35460 KiB
03_l_eq_r_second_08.txt AC 31 ms 35308 KiB
03_l_eq_r_second_09.txt AC 33 ms 35464 KiB
03_l_eq_r_second_10.txt AC 36 ms 35376 KiB
03_l_eq_r_second_11.txt AC 40 ms 35376 KiB
03_l_eq_r_second_12.txt AC 29 ms 35400 KiB
03_l_eq_r_second_13.txt AC 32 ms 35408 KiB
03_l_eq_r_second_14.txt AC 32 ms 35300 KiB
03_l_eq_r_second_15.txt AC 40 ms 35316 KiB
04_random_00.txt AC 37 ms 35308 KiB
04_random_01.txt AC 37 ms 35384 KiB
04_random_02.txt AC 32 ms 35396 KiB
04_random_03.txt AC 33 ms 35384 KiB
04_random_04.txt AC 29 ms 35420 KiB
04_random_05.txt AC 34 ms 35460 KiB
04_random_06.txt AC 37 ms 35392 KiB
04_random_07.txt AC 30 ms 35372 KiB
04_random_08.txt AC 34 ms 35348 KiB
04_random_09.txt AC 31 ms 35472 KiB
05_l_plus_1_eq_r_00.txt AC 34 ms 35452 KiB
05_l_plus_1_eq_r_01.txt AC 34 ms 35476 KiB
05_l_plus_1_eq_r_02.txt AC 33 ms 35416 KiB
06_l_plus_2_eq_r_00.txt AC 28 ms 35388 KiB
06_l_plus_2_eq_r_01.txt AC 35 ms 35468 KiB
06_l_plus_2_eq_r_02.txt AC 32 ms 35444 KiB
07_r_small_00.txt AC 54 ms 35324 KiB
07_r_small_01.txt AC 51 ms 35412 KiB
07_r_small_02.txt AC 47 ms 35412 KiB
07_r_small_03.txt AC 47 ms 35316 KiB
07_r_small_04.txt AC 45 ms 35452 KiB
07_r_small_05.txt AC 49 ms 35372 KiB
07_r_small_06.txt AC 43 ms 35320 KiB
07_r_small_07.txt AC 42 ms 35364 KiB
07_r_small_08.txt AC 44 ms 35376 KiB
07_r_small_09.txt AC 44 ms 35428 KiB
07_r_small_10.txt AC 42 ms 35412 KiB
07_r_small_11.txt AC 41 ms 35400 KiB
07_r_small_12.txt AC 43 ms 35480 KiB
07_r_small_13.txt AC 38 ms 35404 KiB
07_r_small_14.txt AC 44 ms 35364 KiB