結果
| 問題 | No.2165 Let's Play Nim! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-20 20:13:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 166 ms / 2,000 ms |
| コード長 | 1,073 bytes |
| 記録 | |
| コンパイル時間 | 703 ms |
| コンパイル使用メモリ | 72,696 KB |
| 最終ジャッジ日時 | 2025-02-09 17:28:05 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 32 TLE * 6 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n;cin>>n;
vector<int> A(n);
int nw = 0;
for(int i = 0; n > i; i++){
cin>>A[i];
nw ^= A[i];
}
if(nw != 0){
cout << 1 << endl;
bool ok = false;
for(int j = 0; !ok && n > j; j++){
for(int k = 1; A[j] >= k; k++){
if((nw^A[j]^(A[j]-k)) == 0){
cout << j+1 << " " << k << endl;
A[j] -= k;
nw = 0;
ok = true;
break;
}
}
}
int ret;cin>>ret;
if(ret == -1)return 0;
}else{
cout << 0 << endl;
}
while(true){
int tmp;
int i;cin>>i>>tmp;
nw = (nw^A[i-1]^(A[i-1]-tmp));
A[i-1] -= tmp;
int ret;cin>>ret;
if(ret == -1)return 0;
bool ok = false;
for(int j = 0; !ok && n > j; j++){
for(int k = 1; A[j] >= k; k++){
if((nw^A[j]^(A[j]-k)) == 0){
cout << j+1 << " " << k << endl;
A[j] -= k;
nw = 0;
ok = true;
break;
}
}
}
cin>>ret;
if(ret == -1)return 0;
}
}