QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#87304 | #5687. 速战速决 | smallTarjan# | WA | 43ms | 5816kb | C++14 | 938b | 2023-03-12 13:23:38 | 2023-03-12 13:23:42 |
Judging History
answer
#include <cstdio>
#define re int
#define maxn 300005
int n;
int a[maxn];
int vs[maxn];
int ok[maxn];
int top;
int zhan[maxn];
int main()
{
scanf("%d", &n);
re i, j;
for(i = 1;i <= n;i++) vs[i] = 2;
for(i = 1;i <= n;i++) scanf("%d", &a[i]), vs[a[i]]--;
if(n == 1){
printf("-1\n");
return 0;
}
int f = 0;
for(i = 1;i <= n;i++){
for(j = 1;j <= vs[i];j++) zhan[++top] = j;
if(vs[i] == 2) f = i;
}
if(!f) {
printf("-1\n");
return 0;
}
printf("%d\n", n);
printf("%d ", f);
for(i = 1;i < n;i++){
ok[a[i]] = 1;
if(ok[a[i + 1]]) {
printf("%d ", f);
f = a[i + 1];
}
else {
while(zhan[top] == f && top) top--;
printf("%d ", zhan[top--]);
}
}
printf("\n");
return 0;
}
/*
3
1 3 3
1
1
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 43ms
memory: 5816kb
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 2 1 1 1 1 1 2 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 1 1 2 1 2 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 1 2 1 1 2 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 1 1 2 1 2 1 1 ...
result:
FAIL card does not exist