QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#99677 | #4800. Oscar's Round Must Have a Constructive Problem | ckiseki# | TL | 1115ms | 3480kb | C++14 | 1.6kb | 2023-04-23 14:40:49 | 2023-04-23 14:40:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define orange(a...) orange_(#a, a)
#define debug(a...) debug_(#a, a)
template <typename i>
void orange_(const char * s, i l, i r) {
cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; l != r; l++)
cerr << (f++ ? " " : "") << *l;
cerr << " ]\e[0m\n";
}
template <typename ...T>
void debug_(const char * s, T ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int cnt = sizeof...(T);
(..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
int main() {
mt19937 rng(114514);
cin.tie(nullptr)->sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<int> a(n), p(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
--a[i];
}
bool allsame = true;
for (int i = 1; i < n; i++) {
if (a[i] != a[0])
allsame = false;
}
if (allsame) {
cout << "NO\n";
continue;
}
iota(p.begin(), p.end(), 0);
do {
shuffle(p.begin(), p.end(), rng);
bool ok = true;
for (int i = 0; i < n; i++)
if (a[i] == p[i])
ok = false;
if (ok)
break;
} while (true);
cout << "YES\n";
for (int i = 0; i < n; i++)
cout << p[i]+1 << (i+1==n ? '\n' : ' ');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3404kb
input:
3 3 3 3 3 3 3 2 1 6 1 1 4 5 1 4
output:
NO YES 1 3 2 YES 4 2 6 1 5 3
result:
ok ok
Test #2:
score: 0
Accepted
time: 50ms
memory: 3480kb
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 3 2 1 YES 3 1 2 YES 2 3 1 YES 3 1 2 YES 2 1 3 YES 3 2 1 YES 3 1 2 YES 1 2 3 YES 3 2 1 YES 3 2 1 YES 1 3 2 NO YES 3 1 2 YES 3 1 2 YES 1 2 3 YES 3 2 1 YES 1 2 3 YES 2 3 1 YES 2 3 1 YES 1 3 2 YES 2 3 1 YES 2 3 1 YES 1 2 3 YES 1 2 3 NO NO YES 2 3 4 1 YES 4 2 3 1...
result:
ok ok
Test #3:
score: 0
Accepted
time: 16ms
memory: 3392kb
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: 72ms
memory: 3436kb
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 8 4 6 9 2 3 7 1 10 5 YES 5 8 9 7 1 6 4 3 10 2 YES 2 7 1 10 4 3 6 8 9 5 YES 8 2 5 7 1 10 9 4 3 6 YES 9 3 7 4 2 6 8 10 5 1 YES 10 9 2 7 6 3 1 8 4 5 YES 1 4 8 2 3 9 5 10 6 7 NO YES 1 3 8 2 9 5 4 6 7 10 YES 1 7 6 2 8 4 3 10 9 5 YES 10 2 1 9 7 8 6 4 3 5 NO NO YES 2 6 4 3 5 9 1 7 10 8 YES 3 5 9 4 10 6...
result:
ok ok
Test #5:
score: 0
Accepted
time: 170ms
memory: 3396kb
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 91 95 51 11 40 29 39 17 59 68 18 80 72 57 28 64 10 97 4 42 45 25 75 8 63 5 38 31 98 22 71 23 77 37 85 81 52 6 48 56 44 26 54 47 32 88 87 73 27 99 55 19 30 89 100 9 61 60 96 82 53 94 92 67 74 83 76 35 20 15 65 33 21 93 62 69 7 86 16 66 79 12 24 46 84 2 78 49 43 50 34 3 58 1 70 36 41 13 14 90 YES ...
result:
ok ok
Test #6:
score: 0
Accepted
time: 1115ms
memory: 3396kb
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 198 872 206 374 654 980 919 423 334 261 345 371 233 31 415 116 468 19 435 357 184 981 204 257 169 25 447 963 45 410 46 544 615 754 913 575 190 180 971 77 328 457 187 284 267 974 344 252 762 135 101 885 929 408 171 937 384 69 589 505 412 133 700 855 194 127 557 106 750 229 50 608 701 370...
result:
ok ok
Test #7:
score: -100
Time Limit Exceeded
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 3488 7777 1758 9787 287 376 6809 9036 4368 6240 5072 6286 1095 4350 347 3975 7920 3930 3723 9435 2501 6904 7514 3528 1709 3299 6411 2415 7736 8859 3611 4752 1649 4513 5728 1559 236 6082 2842 3243 6868 7266 9944 9909 690 3277 5658 7181 8080 2086 8451 7345 4510 2403 354 5494 1951 838 1509 4491 880...