QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864765 | #4800. Oscar's Round Must Have a Constructive Problem | Wu_Ren | AC ✓ | 54ms | 5376kb | C++14 | 782b | 2025-01-21 01:15:44 | 2025-01-21 01:15:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n,a[100010],c[100010],r[100010],p[100010];
void sol(){
scanf("%d",&n);
for(int i=1;i<=n;i++) c[i]=0;
for(int i=1;i<=n;i++) scanf("%d",&a[i]),c[a[i]]++;
for(int i=2;i<=n;i++) c[i]+=c[i-1];
for(int i=n;i>=1;i--) r[i]=c[a[i]]--;
sort(a+1,a+n+1);
for(int i=1;i<=n;i++) p[i]=n-i+1;
for(int i=1;i<=n;i++) if(p[i]==a[i]){
if(a[1]!=p[i]){
swap(p[i],p[1]);
break;
}
if(a[n]!=p[i]){
swap(p[i],p[n]);
break;
}
puts("NO");
return;
}
puts("YES");
for(int i=1;i<=n;i++) printf("%d ",p[r[i]]);
puts("");
}
int main(){
int T;
scanf("%d",&T);
while(T--) sol();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
input:
3 3 3 3 3 3 3 2 1 6 1 1 4 5 1 4
output:
NO YES 1 3 2 YES 6 5 3 1 4 2
result:
ok ok
Test #2:
score: 0
Accepted
time: 29ms
memory: 3840kb
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 3 2 1 YES 3 2 1 YES 3 1 2 YES 2 3 1 YES 2 3 1 YES 3 1 2 YES 2 1 3 YES 3 2 1 YES 1 3 2 YES 3 2 1 YES 3 2 1 YES 3 1 2 NO YES 3 1 2 YES 3 1 2 YES 3 2 1 YES 3 2 1 YES 1 3 2 YES 1 2 3 YES 2 3 1 YES 1 3 2 YES 2 3 1 YES 2 3 1 YES 2 1 3 YES 2 1 3 NO ...
result:
ok ok
Test #3:
score: 0
Accepted
time: 10ms
memory: 3840kb
input:
100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
result:
ok ok
Test #4:
score: 0
Accepted
time: 44ms
memory: 3840kb
input:
50000 10 3 3 3 3 3 6 3 3 3 3 10 4 5 5 5 5 5 5 5 5 5 10 8 8 8 8 8 8 8 1 8 8 10 6 6 6 6 6 6 6 6 6 2 10 4 4 4 5 4 4 4 4 4 4 10 4 5 4 4 4 10 10 4 5 10 10 8 10 10 6 4 8 4 7 10 4 10 8 8 8 8 8 8 8 8 8 8 10 4 4 4 9 10 10 10 10 4 1 10 4 4 4 4 4 1 4 4 4 4 10 5 5 5 5 6 6 5 6 5 6 10 10 10 10 10 10 10 10 10 10 1...
output:
YES 10 9 8 7 6 3 5 4 1 2 YES 5 9 8 7 6 10 4 3 2 1 YES 9 10 7 6 5 4 3 8 2 1 YES 9 8 7 10 5 4 3 2 1 6 YES 10 9 8 4 7 6 5 1 3 2 YES 5 10 9 8 7 3 2 6 4 1 YES 5 3 2 7 10 4 9 6 1 8 NO YES 9 8 7 5 4 3 2 1 6 10 YES 9 8 7 6 5 4 10 3 2 1 YES 10 9 8 7 4 3 6 2 1 5 NO NO YES 6 5 4 7 3 10 2 9 1 8 YES 3...
result:
ok ok
Test #5:
score: 0
Accepted
time: 42ms
memory: 3840kb
input:
5000 100 37 37 37 58 58 58 58 58 58 58 37 58 37 37 37 58 37 37 37 37 58 58 37 37 37 37 58 37 58 58 58 58 37 58 58 58 37 58 37 37 37 37 58 37 37 37 58 37 37 58 37 37 37 58 37 37 58 37 58 58 58 58 37 37 58 58 58 37 37 58 58 37 37 58 37 58 58 37 58 58 58 37 58 58 37 58 58 58 37 58 58 58 37 58 58 37 58 ...
output:
YES 100 99 98 52 51 50 49 48 47 46 97 45 96 95 94 44 93 92 91 90 43 42 89 88 87 86 41 85 40 39 38 37 84 36 35 34 83 33 82 81 80 79 32 78 77 76 31 75 74 30 73 72 71 29 70 69 28 68 27 26 25 24 67 66 23 22 21 65 64 20 19 63 62 18 61 17 16 60 15 14 13 59 12 11 58 10 9 8 57 7 6 5 56 4 3 55 2 54 53 1 YES...
result:
ok ok
Test #6:
score: 0
Accepted
time: 42ms
memory: 3840kb
input:
500 1000 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452...
output:
NO NO NO YES 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928...
result:
ok ok
Test #7:
score: 0
Accepted
time: 45ms
memory: 3968kb
input:
50 10000 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9931 9...
output:
YES 9999 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9942 9941 9...
result:
ok ok
Test #8:
score: 0
Accepted
time: 48ms
memory: 4224kb
input:
20 25000 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2181 2...
output:
YES 25000 24999 24998 24997 24996 24995 24994 24993 24992 24991 24990 24989 24988 24987 24986 24985 24984 24983 24982 24981 24980 24979 24978 24977 24976 24975 24974 24973 24972 24971 24970 24969 24968 24967 24966 24965 24964 24963 24962 24961 24960 24959 24958 24957 24956 24955 24954 24953 24952 24...
result:
ok ok
Test #9:
score: 0
Accepted
time: 54ms
memory: 4480kb
input:
10 50000 32825 31708 22702 32825 22702 31708 32825 32825 9333 31708 32825 46864 22702 32825 31708 31708 22702 22702 31708 46864 9333 9333 1785 31708 22702 9333 1785 32825 31708 22702 46864 32825 9333 46864 9333 35050 31708 1785 46864 9333 32825 1785 22702 31708 22702 1785 46864 32825 1785 35050 9333...
output:
YES 21368 28516 35686 21367 35685 28515 21366 21365 42862 28514 21364 7087 35684 21363 28513 28512 35683 35682 28511 7086 42861 42860 50000 28510 35681 42859 49999 21362 28509 35680 7085 21361 42858 7084 42857 14225 28508 49998 7083 42856 21360 49997 35679 28507 35678 49996 7082 21359 49995 14224 42...
result:
ok ok
Test #10:
score: 0
Accepted
time: 42ms
memory: 5376kb
input:
5 100000 25575 25575 25575 25575 38740 38740 25575 38740 25575 38740 25575 25575 25575 38740 38740 38740 25575 38740 25575 25575 25575 25575 38740 38740 38740 38740 25575 25575 25575 38740 38740 25575 25575 38740 25575 38740 25575 38740 38740 25575 38740 38740 25575 38740 25575 25575 38740 38740 255...
output:
YES 38740 99999 99998 99997 50002 50001 99996 50000 99995 49999 99994 99993 99992 49998 49997 49996 99991 49995 99990 99989 99988 99987 49994 49993 49992 49991 99986 99985 99984 49990 49989 99983 99982 49988 99981 49987 99980 49986 49985 99979 49984 49983 99978 49982 99977 99976 49981 49980 99975 99...
result:
ok ok