QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#465444 | #8837. Increasing Income | ucup-team3548# | WA | 0ms | 3680kb | C++17 | 685b | 2024-07-06 21:55:23 | 2024-07-06 21:55:23 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#define ll long lon
using namespace std;
int T;
int N;
int P[200001];
int Rev[200001];
bool Vis[200001];
int Ans[200001];
int main()
{
scanf("%d",&T);
while(T--)
{
for(int i=1;i<=N;++i)
Vis[i]=false;
scanf("%d",&N);
for(int i=1;i<=N;++i)
{
scanf("%d",&P[i]);
Rev[P[i]]=i;
}
int Now=N;
for(int i=N;i>0;--i)
{
bool Tag=(!Vis[i]&&!Vis[Rev[i]]);
if(!Vis[i])Ans[Now--]=i,Vis[i]=true;
if(!Vis[Rev[i]])Ans[Now--]=Rev[i],Vis[Rev[i]]=true;
if(Tag)
{
if(P[i]>Rev[i])swap(Ans[Now+1],Ans[Now+2]);
}
}
for(int i=1;i<=N;++i)
printf("%d ",Ans[i]);
putchar('\n');
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
input:
3 3 1 2 3 4 2 4 3 1 5 1 5 2 4 3
output:
1 2 3 1 3 2 4 1 3 4 5 2
result:
ok Correct (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 1616kb
input:
153 4 2 4 3 1 4 1 4 2 3 5 2 1 4 5 3 5 1 4 5 3 2 4 1 3 2 4 5 1 5 2 4 3 5 5 3 1 2 4 5 4 1 2 5 3 5 1 2 5 3 4 5 3 1 4 2 5 5 5 4 2 3 1 5 2 1 5 4 3 5 3 4 1 5 2 5 1 4 3 5 2 5 5 1 3 4 2 5 5 3 2 4 1 5 1 5 3 2 4 5 2 4 3 1 5 5 1 5 4 3 2 5 1 2 4 5 3 5 4 2 5 3 1 5 1 3 5 2 4 5 3 1 4 5 2 3 2 1 3 5 1 2 4 3 5 5 5 1 ...
output:
1 3 2 4 1 3 4 2 1 2 3 4 5 1 4 2 3 5 1 2 3 4 1 3 4 5 2 2 3 4 5 1 2 3 1 4 5 1 2 4 5 3 2 1 3 4 5 3 4 2 1 5 1 2 4 3 5 1 3 2 4 5 1 3 2 4 5 2 3 4 5 1 2 3 4 1 5 1 3 4 5 2 1 3 2 4 5 1 3 4 2 5 1 2 3 4 5 2 4 1 3 5 1 2 4 5 3 2 1 3 4 5 1 2 3 1 2 3 4 5 2 3 4 5 1 1 3 4 5 2 3 4 2 5 1 2 ...
result:
wrong answer Jury found better answer than participant (test case 4)