QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#85244 | #5687. 速战速决 | liaopengfei | WA | 357ms | 19468kb | C++17 | 1.2kb | 2023-03-07 13:54:08 | 2023-03-07 13:54:11 |
Judging History
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||(res.empty())){
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;
bf[++bt]=t;
res.erase(t);
}
bf[++bt]=b[i];
res.erase(b[i]);
now[b[i]]=1;
// For(j,1,bt) cout<<bf[j]<<" ";cout<<bt<<bt<<" "<<i<<endl;
}
For(i,x,n+x-1) printf("%d ",ans[i]);
}
int main(){
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
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: 357ms
memory: 19468kb
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 2 3 4 7 8 9 10 12 13 14 15 16 17 18 20 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 48 50 51 52 54 55 58 59 60 62 63 64 65 66 67 68 69 70 72 73 75 77 79 80 81 83 84 85 86 87 88 89 91 92 95 96 97 99 100 101 103 105 106 107 108 109 110 111 114 115 116 117 118...
result:
FAIL card does not exist