QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#650341#9424. Stop the Castle 2sevenki#WA 2ms13908kbC++17915b2024-10-18 14:43:212024-10-18 14:43:28

Judging History

This is the latest submission verdict.

  • [2024-10-18 14:43:28]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 13908kb
  • [2024-10-18 14:43:21]
  • Submitted

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)