QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#515741 | #9176. Non-Interactive Nim | EZGG | WA | 136ms | 3600kb | C++23 | 2.0kb | 2024-08-11 22:54:04 | 2024-08-11 22:54:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
int n;
vector<int> a[100];
cin>>n;
for(int i=1;i<=n;i++){
int x;
cin>>x;
bitset<66> bt(x);
for(int j=0;j<66;j++){
if(bt[j]){
a[j].push_back(i);
}
}
}
int f=1;
vector<int> ans1;
vector<int>ans2;
for(int i=0;i<100;i++){
int xi=-1;
f=1;
for(int j=0;j<70;j++){
if(a[j].size()>0){
f=0;
if(a[j].size()==2){
xi=j;
break;
}
}
}
if(f==1){
break;
}
if(xi==-1){
cout<<"-1\n";
return;
}
int x=a[xi][0],y=a[xi][1];
int an=0;
for(int j=0;j<70;j++){
int fx=-1,fy=-1;
for(int k=0;k<a[j].size();k++){
if(a[j][k]==x){
fx=k;
}
if(a[j][k]==y){
fy=k;
}
}
if(fx!=-1&&fy!=-1){
if(fx>fy){
a[j].erase(a[j].begin()+fx);
a[j].erase(a[j].begin()+fy);
}
else{
a[j].erase(a[j].begin()+fy);
a[j].erase(a[j].begin()+fx);
}
an+=(1<<j);
}
}
ans1.push_back(an);
ans2.push_back(x);
}
if(f==0){
cout<<"-1\n";
return;
}
cout<<ans1.size()<<"\n";
for(int i=0;i<ans1.size();i++){
cout<<ans2[i]<<" "<<ans1[i]<<"\n";
}
return;
}
signed main()
{
#if !LOCAL
ios::sync_with_stdio(0);
cin.tie(0);
#endif
int tt = 1;
cin >> tt;
while (tt--)
solve();
#if LOCAL
system("pause");
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
2 4 4 2 7 1 4 1 1 1 1
output:
3 3 1 2 2 1 4 -1
result:
ok OK 1 yes 1 no (2 test cases)
Test #2:
score: 0
Accepted
time: 29ms
memory: 3536kb
input:
50000 2 3 3 2 2 2 2 3 3 2 2 2 2 3 3 2 3 3 2 1 1 2 1 1 2 1 1 2 2 2 2 2 2 2 3 3 2 2 2 2 1 1 2 3 3 2 1 1 2 1 1 2 1 1 2 3 3 2 1 1 2 1 1 2 3 3 2 2 2 2 3 3 2 3 3 2 2 2 2 1 1 2 3 3 2 2 2 2 2 2 2 3 3 2 3 3 2 1 1 2 1 1 2 1 1 2 3 3 2 3 3 2 1 1 2 1 1 2 3 3 2 2 2 2 2 2 2 2 2 2 1 1 2 1 1 2 2 2 2 2 2 2 1 1 2 3 3 ...
output:
1 1 3 1 1 2 1 1 3 1 1 2 1 1 3 1 1 3 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 3 1 1 2 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 3 1 1 2 1 1 3 1 1 3 1 1 2 1 1 1 1 1 3 1 1 2 1 1 2 1 1 3 1 1 3 1 1 1 1 1 1 1 1 1 1 1 3 1 1 3 1 1 1 1 1 1 1 1 3 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 3 1 1 3 ...
result:
ok OK 50000 yes 0 no (50000 test cases)
Test #3:
score: -100
Wrong Answer
time: 136ms
memory: 3600kb
input:
50000 2 89846347117873058 89846347117873058 2 416235892302498917 416235892302498917 2 332154513003612985 332154513003612985 2 43960216631774959 43960216631774959 2 353215896487285554 353215896487285554 2 38296945667390613 38296945667390613 2 209150071115726640 209150071115726640 2 48610805835417777 ...
output:
1 1 -711787928 1 1 -1120137029 1 1 314284030 1 1 -1993196412 1 1 -1945357522 1 1 -2096837773 1 1 -1333736431 1 1 918387702 1 1 -1541169328 1 1 -178365667 1 1 1439561304 1 1 -456553136 1 1 -1794967250 1 1 1761511335 1 1 1732223979 1 1 -1286000340 1 1 -1418096650 1 1 452846075 1 1 -554375289 1 1 -2066...
result:
wrong answer Integer parameter [name=x] equals to -711787928, violates the range [1, 89846347117873058] (test case 1)