QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#269541 | #5687. 速战速决 | myusername# | WA | 28ms | 13260kb | C++20 | 1.5kb | 2023-11-29 18:44:05 | 2023-11-29 18:44:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[300030];
int cnt[300030];
int op[300030];
int rec[300030];
bool ha[300030];
#define pok stk
stack<int>pok;
bool used[300030];
bool vis[300030];
signed main()
{
int qwertyuiopasdfghjklzxcvbnm=1;
// cin>>qwertyuiopasdfghjklzxcvbnm;
while(qwertyuiopasdfghjklzxcvbnm--)
{
scanf("%lld",&n);
for(int i=0;i<n;i++)scanf("%lld",a+i);
for(int i=1;i<=n;i++)cnt[i]=2;
for(int i=0;i<n;i++)cnt[a[i]]--;
int m=0;
queue<int>v;
for(int i=1;i<=n;i++)if(cnt[i]==2)m=i,v.push(i);
if(m)
{
for(int i=0;i<n;i++)
{
if(vis[a[i]])
{
op[i]=rec[a[i]];
while(stk.top()!=op[i])
{
int x=stk.top();
vis[x]=0;
stk.pop();
}
stk.pop();
stk.push(a[i]);
}
else
{
if(cnt[a[i]]==1||used[a[i]])
{
op[i]=a[i];
ha[i]=1;
// cout<<i<<endl;
}
else
{
op[i]=v.front();v.pop();
rec[a[i]]=op[i];
}
}
used[a[i]]=1;
}
op[n]=m;
// printf("%lld\n",n);
// for(int i=0;i<=n;i++)printf("%lld ",op[i]);
for(int i=n-1;i>=0;i--)if(ha[i])swap(op[i],op[i+1]);
printf("%lld\n",n);
for(int i=0;i<n;i++)printf("%lld ",op[i]);
return 0;
}
else
{
if(n==1)
{
cout<<-1;
return 0;
}
printf("%lld\n%lld ",n+2,a[n-1]);
for(int i=0;i<n-1;i++)printf("%lld ",a[i]);
printf("%lld %lld",a[0],a[0]);
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 28ms
memory: 13260kb
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 2 195633 37425 205189 128330 4 98406 111454 30346 7 8 107964 10 18 16843 182333 20 195166 188257 172666 26 157060 237654 29 145065 57507 152240 187931 5706 30 214174 38 40 42 61529 85258 74139 44 181186 223348 222711 19237 45 20487 48 139234 51 52 242997 59 62 218467 67 68 69 50360 142553 73 ...
result:
FAIL card does not exist