QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#417250#7346. Frogsunputdownable#WA 1ms3652kbC++171.3kb2024-05-22 16:43:052024-05-22 16:43:06

Judging History

你现在查看的是最新测评结果

  • [2024-05-22 16:43:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3652kb
  • [2024-05-22 16:43:05]
  • 提交

answer

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#include <bits/stdc++.h>
// #define int long long
#define i64 long long
#define pii pair <int, int> 
using namespace std;
inline int read(void) {
    int x=0,sgn=1; char ch=getchar();
    while(ch<48||57<ch) {if(ch==45)sgn=0;ch=getchar();}
    while(47<ch&&ch<58) {x=x*10+ch-48;   ch=getchar();}
    return sgn? x:-x;
}
void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
/*
    write((Ans%p+p)%p); pls
*/
int n;
int a[200005],v[200005];
int stk[200005],top; 
signed main() {
    // freopen("localinput","r",stdin);
    // freopen("localoutput","w",stdout);
    n=read();
    for(int i=1; i<n; ++i) v[i]=read();
    for(int i=1; i<n; ++i) if(v[i]&1) return puts("No"),0;
    for(int i=1; i<n; ++i) v[i]/=2;
    for(int i=1; i<=n; ++i) {
        if(v[i]==top+1) {
            stk[++top]=i;
        } else if(v[i]==top) {
            a[i]=i;
        } else if(v[i]==top-1) {
            int b=stk[top]; --top;
            a[i]=b;
            a[b]=i;
        } else return puts("No"),0;
    }
    for(int i=1; i<=n; ++i) write(a[i]),putchar(" \n"[i==n]);
    // fprintf(stderr,"%.4lf\n",1.0*clock()/CLOCKS_PER_SEC);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3652kb

input:

5
2 4 2 2

output:

5 3 2 4 1

result:

wrong answer Line [name=verdict] equals to "5 3 2 4 1", doesn't correspond to pattern "Yes|No"