結果

問題 No.2165 Let's Play Nim!
ユーザー 👑 hos.lyrichos.lyric
提出日時 2022-12-16 00:10:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 1,970 bytes
コンパイル時間 929 ms
コンパイル使用メモリ 98,384 KB
実行使用メモリ 24,408 KB
平均クエリ数 863.56
最終ジャッジ日時 2023-08-09 09:21:33
合計ジャッジ時間 17,307 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
23,388 KB
testcase_01 AC 129 ms
24,036 KB
testcase_02 AC 139 ms
24,288 KB
testcase_03 AC 90 ms
24,072 KB
testcase_04 AC 27 ms
23,424 KB
testcase_05 AC 33 ms
23,652 KB
testcase_06 AC 32 ms
24,024 KB
testcase_07 AC 31 ms
24,336 KB
testcase_08 AC 94 ms
24,048 KB
testcase_09 AC 27 ms
23,424 KB
testcase_10 AC 34 ms
23,376 KB
testcase_11 AC 140 ms
24,036 KB
testcase_12 AC 120 ms
24,408 KB
testcase_13 AC 26 ms
23,676 KB
testcase_14 AC 30 ms
24,072 KB
testcase_15 AC 26 ms
24,036 KB
testcase_16 AC 114 ms
24,048 KB
testcase_17 AC 63 ms
23,412 KB
testcase_18 AC 199 ms
24,072 KB
testcase_19 AC 26 ms
23,424 KB
testcase_20 AC 30 ms
23,844 KB
testcase_21 AC 52 ms
23,640 KB
testcase_22 AC 45 ms
23,856 KB
testcase_23 AC 43 ms
23,652 KB
testcase_24 AC 39 ms
24,288 KB
testcase_25 AC 77 ms
23,556 KB
testcase_26 AC 142 ms
23,676 KB
testcase_27 AC 46 ms
24,372 KB
testcase_28 AC 68 ms
24,060 KB
testcase_29 AC 25 ms
24,324 KB
testcase_30 AC 25 ms
23,844 KB
testcase_31 AC 25 ms
24,288 KB
testcase_32 AC 93 ms
23,400 KB
evil_2_big_1.txt AC 1,783 ms
24,384 KB
evil_2_big_2.txt TLE -
evil_2_big_3.txt AC 1,756 ms
23,376 KB
evil_big_1.txt AC 1,974 ms
23,412 KB
evil_big_2.txt TLE -
evil_big_3.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


int N;
vector<int> A;

int main() {
  scanf("%d", &N);
  A.resize(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  
  int now = 0;
  for (int i = 0; i < N; ++i) {
    now ^= A[i];
  }
  printf("%d\n", (now != 0) ? 1 : 0);
  fflush(stdout);
  for (; ; ) {
    if (now != 0) {
      for (int i = 0; i < N; ++i) {
        if (A[i] >= (A[i] ^ now)) {
          printf("%d %d\n", i + 1, A[i] - (A[i] ^ now));
          fflush(stdout);
          A[i] ^= now;
          now = 0;
          break;
        }
      }
      int res;
      scanf("%d", &res);
      if (res == -1) exit(0);
    }
    {
      int i, k;
      scanf("%d%d", &i, &k);
      --i;
      now ^= A[i] ^ (A[i] - k);
      A[i] -= k;
      int res;
      scanf("%d", &res);
      if (res == -1) exit(0);
    }
  }
  
  return 0;
}
0