QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#85245#5687. 速战速决liaopengfeiWA 220ms19252kbC++171.2kb2023-03-07 14:04:062023-03-07 14:04:07

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-07 14:04:07]
  • Judged
  • Verdict: WA
  • Time: 220ms
  • Memory: 19252kb
  • [2023-03-07 14:04:06]
  • Submitted

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
const int N = 6e5 + 15;
set<int> res;
int n,now[N],b[N],a[N],cur,ans[N],bf[N],c[N];
void doit(int x){
	int siz=0,bt=0;
		For(i,x,n+x-1){
			int t=*res.begin();
			if(now[b[i]]==1||siz==0){
				ans[i]=cur;
				if(siz==0){
					bf[++bt]=cur; now[cur]=1;
					siz=1;
				}else{
					while(bf[bt]!=cur) 
						res.insert(bf[bt]),now[bf[bt]]=0,--bt;
					now[cur]=0,--bt;
					siz=0;
				}
			}else{
				ans[i]=t;
				if(now[t]){
					while(bf[bt]!=t)
						res.insert(bf[bt]),now[bf[bt]]=0,--bt;
					now[t]=0,--bt;
				}else bf[++bt]=t;
			}
			bf[++bt]=b[i];
			if(!siz) res.erase(b[i]);
			now[b[i]]=1;
		}
		For(i,x,n+x-1) printf("%d ",ans[i]);
}
int main(){
	scanf("%d",&n);
	bool qq=0;
	For(i,1,n){
		scanf("%d",&b[i]); 
		c[b[i]]++;
		if(c[b[i]]>1) qq=1;
	}
	For(i,1,n) if(c[i]==0) cur=i;
	For(i,1,n) if(cur!=i&&c[i]<2) res.insert(i);
	if(qq){
		printf("%d\n",n);
		doit(1);
	}else{
		if(n==1){
			printf("-1\n");
			return 0;
		}
		printf("%d\n%d %d ",n+2,b[2],b[1]);
		b[n+1]=b[n+2]=b[2]; cur=b[1]; 
		res.erase(cur),res.erase(b[2]);
		doit(3);
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 220ms
memory: 19252kb

input:

249665
195633 37425 205189 128330 159707 98406 111454 30346 158516 121742 107964 50039 201395 16843 182333 60177 195166 188257 172666 71779 157060 237654 123572 145065 57507 152240 187931 5706 191077 214174 70950 71272 172767 61529 85258 74139 44633 181186 223348 222711 19237 239887 20487 84130 1392...

output:

249665
249660 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

FAIL card does not exist