QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#199674#7346. Frogswhsyhyyh#WA 0ms3628kbC++141015b2023-10-04 13:40:052023-10-04 13:40:05

Judging History

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

  • [2023-10-04 13:40:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2023-10-04 13:40:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+9;
int n,a[N];
int b[N];
bool flag;
int stk[N];
int top;
struct info {
	int l,r;	
}A[N<<2];
int ans[N];
int cnt;
int xx;
int main(){
    scanf("%d",&n);
    for(int i=1; i<n; ++i) scanf("%d",&a[i]);
    for(int i=1; i<=n; ++i) {
		b[i]=a[i]-a[i-1];
    	if(b[i]!=2&&b[i]!=-2&&b[i]!=0)flag=true;
	}
	if(flag)puts("No");
	else {
		for(int i=1; i<=n; ++i) {
			if(b[i]==2)stk[++top]=i,stk[++top]=i;
			else if(b[i]==-2) {
				while(b[i]<0&&top) {
					A[++cnt]=(info)<%stk[top],i%>;
					--top;
					b[i]++;
				}
				if(b[i]!=0){flag=true;break;}
			}else if(b[i]==0) {
				if(top)A[++cnt]=(info)<%stk[top],i%>,top--;
				else {flag=true;break;}
				stk[++top]=i;
			}
		}
		if(flag) {puts("No");return 0;}
		for(int i=1; i<=cnt; ++i) {
			if(!ans[A[i].l])ans[A[i].l]=A[i].r;
			else if(!ans[A[i].r])ans[A[i].r]=A[i].l;
		}
		puts("Yes");
		for(int i=1; i<=n; ++i)printf("%d ",ans[i]);
	}
	
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

5
2 4 2 2

output:

Yes
4 3 2 5 1 

result:

ok Correct answer.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

4
1 2 3

output:

No

result:

ok Correct answer.

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3576kb

input:

2
0

output:

No

result:

wrong answer Expected YES, found NO on the first line