QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87304#5687. 速战速决smallTarjan#WA 43ms5816kbC++14938b2023-03-12 13:23:382023-03-12 13:23:42

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-12 13:23:42]
  • Judged
  • Verdict: WA
  • Time: 43ms
  • Memory: 5816kb
  • [2023-03-12 13:23:38]
  • Submitted

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