結果
| 問題 |
No.2165 Let's Play Nim!
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2022-12-18 21:47:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,440 bytes |
| コンパイル時間 | 552 ms |
| コンパイル使用メモリ | 59,824 KB |
| 実行使用メモリ | 39,604 KB |
| 平均クエリ数 | 2.92 |
| 最終ジャッジ日時 | 2024-11-17 23:55:39 |
| 合計ジャッジ時間 | 15,732 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 RE * 35 TLE * 2 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2165.cc: No.2165 Let's Play Nim! - yukicoder
*/
#include<cstdio>
#include<set>
#include<algorithm>
#include<utility>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 75000;
enum { First = 1, Second = 0 };
/* typedef */
typedef pair<int,int> pii;
typedef set<pii,greater<pii> > spiig;
/* global variables */
int as[MAX_N];
/* subroutines */
int my_act(spiig &ps, int x) {
pii e = *ps.begin();
int ai = e.first, i = e.second;
int k = ai - (x ^ ai);
ps.erase(ps.begin());
if (ai > k) ps.insert(pii(ai - k, i));
as[i] -= k;
printf("%d %d\n", i + 1, k); fflush(stdout);
int r;
scanf("%d", &r);
return r;
}
int judge_act(spiig &ps) {
int i, k, r;
scanf("%d%d%d", &i, &k, &r), i--;
spiig::iterator sit = ps.find(pii(as[i], i));
int ai = sit->first;
ps.erase(sit);
if (ai > k) ps.insert(pii(ai - k, i));
as[i] -= k;
return (r < 0) ? -1 : ai ^ as[i];
}
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", as + i);
int x = 0;
spiig ps;
for (int i = 0; i < n; i++) {
x ^= as[i];
ps.insert(pii(as[i], i));
}
if (x != 0) {
printf("%d\n", First); fflush(stdout);
my_act(ps, x);
}
else
printf("%d\n", Second); fflush(stdout);
for (;;) {
int x = judge_act(ps);
if (x < 0) break;
int r = my_act(ps, x);
if (r < 0) break;
}
return 0;
}
tnakao0123