QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#199603 | #7346. Frogs | PhantomThreshold# | WA | 0ms | 3468kb | C++20 | 625b | 2023-10-04 13:16:23 | 2023-10-04 13:16:23 |
Judging History
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"