QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#522756 | #9176. Non-Interactive Nim | hhu_yjh | WA | 0ms | 3740kb | C++17 | 1.4kb | 2024-08-17 13:15:09 | 2024-08-17 13:15:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;
const int mod=998244353;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<ll,ll> PII;
ll n,k;
ll a[N];
void solve(){
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
cout<<-1<<endl;
exit(0);
vector<set<int>> cnt(70);
for(int i=1;i<=n;i++){
for(int j=0;j<=62;j++){
if(a[i]>>j&1) cnt[j].insert(i);
}
}
vector<pair<ll,ll>> ans;
auto work=[&](ll x,ll y){
ll temp=0;
for(int k=62;k>=0;k--){
if((a[x]>>k&1)&&(a[y]>>k&1)){
cnt[k].erase(x),cnt[k].erase(y);
a[x]-=1ll<<k,a[y]-=1ll<<k;
temp+=1ll<<k;
}
}
ans.push_back({x,temp});
};
for(int i=62;i>=0;i--){
if(cnt[i].size()==0) continue;
if(cnt[i].size()!=2){
cout<<-1<<endl;
return;
}
ll x=*cnt[i].begin();
cnt[i].erase(x);
ll y=*cnt[i].begin();
cnt[i].clear();
work(x,y);
}
cout<<ans.size()<<endl;
for(auto j:ans){
cout<<j.first<<' '<<j.second<<endl;
}
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
cin>>t;
// t=1;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3740kb
input:
2 4 4 2 7 1 4 1 1 1 1
output:
-1
result:
wrong answer judge has answer but participant doesn't (test case 1)