QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#199603#7346. FrogsPhantomThreshold#WA 0ms3468kbC++20625b2023-10-04 13:16:232023-10-04 13:16:23

Judging History

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

  • [2023-10-04 13:16:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3468kb
  • [2023-10-04 13:16:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n+5),b(n+5),ans(n+5);
	for(int i=1;i<=n;i++)
	{
		if(i!=n)cin>>a[i];
		if(a[i]-a[i-1]==2)b[i]=1;
		else if(a[i]-a[i-1]==-2)b[i]=-1;
		else if(a[i]==a[i-1])b[i]=0;
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=1;i<=n;i++)ans[i]=i;
	stack<int> st;
	for(int i=1;i<=n;i++)
	{
		if(b[i]==1)
			st.push(i);
		else if(b[i]==-1)
		{
			int u=st.top();st.pop();
			swap(ans[i],ans[u]);
		}
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<" \n"[i==n];
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3468kb

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"