QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#600842 | #4800. Oscar's Round Must Have a Constructive Problem | HTensor# | AC ✓ | 44ms | 9280kb | C++23 | 1.5kb | 2024-09-29 19:38:33 | 2024-09-29 19:38:33 |
Judging History
answer
#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x << ": " << x << "\n"
#define SZ(x) ((int)(x).size())
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
using ll = long long;
const int inf = 0x3f3f3f3f3f3f3f3fLL;
#define MULTI_TEST
void solve() {
int n; cin >> n;
vector<int> a(n + 1), pos(n + 1), ans(n + 1);
vi dis;
int cnt = 0;
for(int i = 1; i <= n; i++) {
cin >> a[i];
if(!pos[a[i]]) {
++cnt;
}
pos[a[i]] = i;
}
if(cnt == 1) {
cout << "NO\n";
return ;
}
vi val, per;
for(int i = 1; i <= n; i++) {
if(pos[i]) {
val.push_back(i);
per.push_back(pos[i]);
} else dis.push_back(i);
}
vector<int> per2(per.begin() + 1, per.end());
per2.push_back(*per.begin());
for(int i = 0; i < SZ(per2); i++) {
ans[per2[i]] = val[i];
}
for(int i = 1; i <= n; i++) {
if(!ans[i]) {
ans[i] = dis.back(); dis.pop_back();
}
}
cout<< "YES\n";
for(int i = 1; i <= n; i++) {
cout << ans[i] << " ";
}
cout << "\n";
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
#ifdef MULTI_TEST
int T; cin >> T;
#else
int T = 1;
#endif
while(T--) solve();
return 0;
}
/*
3
3
3 3 3
3
3 2 1
6
1 1 4 5 1 4
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
3 3 3 3 3 3 3 2 1 6 1 1 4 5 1 4
output:
NO YES 2 1 3 YES 6 3 2 4 5 1
result:
ok ok
Test #2:
score: 0
Accepted
time: 39ms
memory: 3796kb
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 2 3 1 YES 3 1 2 YES 2 3 1 YES 3 1 2 YES 2 1 3 YES 3 2 1 YES 3 2 1 YES 1 3 2 YES 3 2 1 YES 1 3 2 YES 3 1 2 NO YES 1 3 2 YES 1 2 3 YES 1 2 3 YES 3 1 2 YES 1 2 3 YES 2 3 1 YES 2 3 1 YES 2 1 3 YES 2 1 3 YES 1 3 2 YES 2 1 3 YES 1 2 3 NO ...
result:
ok ok
Test #3:
score: 0
Accepted
time: 12ms
memory: 3564kb
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: 3556kb
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 5 3 4 2 1 6 YES 5 10 9 8 7 6 3 2 1 4 YES 10 9 7 6 5 4 3 8 2 1 YES 10 9 8 7 5 4 3 1 2 6 YES 10 9 8 4 7 6 3 2 1 5 YES 9 8 7 6 3 2 1 10 4 5 YES 9 5 3 4 2 7 1 6 8 10 NO YES 8 7 6 4 5 3 2 9 1 10 YES 10 9 8 7 6 4 5 3 2 1 YES 10 9 8 7 4 3 2 1 6 5 NO NO YES 10 8 7 3 5 4 2 1 6 9 YES 1...
result:
ok ok
Test #5:
score: 0
Accepted
time: 30ms
memory: 3636kb
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 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 58 37 YES...
result:
ok ok
Test #6:
score: 0
Accepted
time: 31ms
memory: 3696kb
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 1000 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 92...
result:
ok ok
Test #7:
score: 0
Accepted
time: 39ms
memory: 4224kb
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 10000 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 ...
result:
ok ok
Test #8:
score: 0
Accepted
time: 34ms
memory: 4812kb
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: 41ms
memory: 6480kb
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 50000 49999 49998 49997 49996 49995 49994 49993 49992 49991 49990 49989 49988 49987 49986 49985 49984 49983 49982 49981 49980 49979 49978 49977 49976 49975 49974 49973 49972 49971 49970 49969 49968 49967 49966 49965 49964 49963 49962 49961 49960 49959 49958 49957 49956 49955 49954 49953 49952 49...
result:
ok ok
Test #10:
score: 0
Accepted
time: 33ms
memory: 9280kb
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 100000 99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952 9...
result:
ok ok