QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#650341 | #9424. Stop the Castle 2 | sevenki# | WA | 2ms | 13908kb | C++17 | 915b | 2024-10-18 14:43:21 | 2024-10-18 14:43:28 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e6+10;
int a[N],res;
int Log[N];
int c[N];
bool vis[N];
int sum,ans[N];
priority_queue<int,vector<int>,greater<int> > p;
void solve(){
int n;cin>>n;
while(p.size()) p.pop();
for(int i=0;i<n;i++){
p.push(i);
}
sum=0;
for(int i=0;i<n;i++){
int x=p.top();p.pop();
if((sum^x)==0){
//cout<<x<<" ";
if(!p.size()){
cout<<"impossible"<<endl;
return ;
}
else{
int y=p.top();p.pop();
//cout<<y<<" ";
ans[i]=y;
sum^=y;
p.push(x);
}
}
else ans[i]=x,sum^=x;
}
for(int i=0;i<n;i++) cout<<ans[i]<<" ";
cout<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
Log[0]=1;
for(int i=1;i<=25;i++){
Log[i]=Log[i-1]*2;
if(Log[i]<=1000000&&Log[i]!=2) c[Log[i]-1]=1;
}
while(t--) solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 13908kb
input:
3 8 6 4 1 3 2 1 2 6 4 1 4 7 6 1 6 3 6 6 2 3 3 1 4 3 4 6 5 2 6 4 3 2 1 10 12 10 10 10 11 1 4 1 5 1 3 2 1 1 2 1 2 2 2 3
output:
impossible 1 0 2 4 3 5 impossible
result:
wrong output format Expected integer, but "impossible" found (test case 1)