QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#434511 | #4800. Oscar's Round Must Have a Constructive Problem | ship2077 | WA | 19ms | 3956kb | C++14 | 619b | 2024-06-08 16:26:29 | 2024-06-08 16:26:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int M=1e5+5;
int n,cnt,num,p[M],per[M];
int read(){
int x=0;char ch=getchar();
while (!isdigit(ch)) ch=getchar();
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x;
}
void solve(){ n=read();num=0;
for (int i=1;i<=n;i++) p[i]=read();
for (int i=1;i<=n;i++) num+=p[i]==p[1];
if (num==n) return puts("NO"),void();
iota(per+1,per+n+1,1);
for (int i=1;i<=n;i++) if (per[i]==p[i])
swap(per[i],per[i%n+1]); puts("YES");
for (int i=1;i<=n;i++) printf("%d%c",per[i]," \n"[i==n]);
}
int main(){int T=read();while (T--) solve();return 0;}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3876kb
input:
3 3 3 3 3 3 3 2 1 6 1 1 4 5 1 4
output:
NO YES 1 3 2 YES 2 3 1 4 5 6
result:
ok ok
Test #2:
score: -100
Wrong Answer
time: 19ms
memory: 3956kb
input:
50069 1 1 2 1 1 2 1 2 2 2 1 2 2 2 3 1 1 1 3 1 1 2 3 1 1 3 3 1 2 1 3 1 2 2 3 1 2 3 3 1 3 1 3 1 3 2 3 1 3 3 3 2 1 1 3 2 1 2 3 2 1 3 3 2 2 1 3 2 2 2 3 2 2 3 3 2 3 1 3 2 3 2 3 2 3 3 3 3 1 1 3 3 1 2 3 3 1 3 3 3 2 1 3 3 2 2 3 3 2 3 3 3 3 1 3 3 3 2 3 3 3 3 4 1 1 1 1 4 1 1 1 2 4 1 1 1 3 4 1 1 1 4 4 1 1 2 1 ...
output:
NO NO YES 2 1 YES 1 2 NO NO YES 2 3 1 YES 2 3 1 YES 2 1 3 YES 2 1 3 YES 3 1 2 YES 2 1 3 YES 2 1 3 YES 3 1 2 YES 1 2 3 YES 1 2 3 YES 3 2 1 YES 1 3 2 NO YES 1 3 2 YES 1 2 3 YES 1 2 3 YES 3 2 1 YES 1 2 3 YES 1 2 3 YES 3 2 1 YES 1 3 2 YES 2 3 1 YES 1 3 2 YES 1 2 3 YES 1 2 3 NO NO YES 2 3 4 1 YES 2 3 4 1...
result:
wrong answer P_1 == A_1.