結果
| 問題 |
No.2165 Let's Play Nim!
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-12-16 00:08:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,050 bytes |
| コンパイル時間 | 4,374 ms |
| コンパイル使用メモリ | 253,152 KB |
| 最終ジャッジ日時 | 2025-02-09 14:04:38 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 RE * 34 TLE * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:63:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
63 | scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001
vector<vector<int>> is(30);
vector<int> a;
int X = 0;
void Go(){
int m = 29;
for(int i=29;i>=0;i--){
if((X>>i)&1){
m = i;
break;
}
}
while(true){
int ii = is[m].back();
is[m].pop_back();
if((a[ii]>>m)&1){
cout<<ii+1<<' '<<a[ii] - (a[ii]^X)<<endl;
a[ii] ^= X;
X = 0;
break;
}
}
int r;
cin>>r;
if(r==-1)exit(0);
}
void Other(){
int i,k;
cin>>i>>k;
i--;
X ^= a[i];
a[i] -= k;
X ^= a[i];
rep(j,30){
if((a[i]>>j)&1)is[j].push_back(i);
}
int r;
cin>>r;
if(r==-1)exit(0);
}
int main(){
int n;
cin>>n;
a.resize(n);
rep(i,n){
scanf("%d",&a[i]);
rep(j,30){
if((a[i]>>j)&1)is[j].push_back(i);
}
X ^= a[i];
}
if(X!=0){
cout<<1<<endl;
Go();
}
else{
cout<<0<<endl;
}
while(true){
Other();
Go();
}
return 0;
}
沙耶花