QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#666703 | #7158. Carnival General | blackslex# | 40 | 23ms | 5932kb | C++14 | 758b | 2024-10-22 19:40:36 | 2024-10-22 19:40:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
scanf("%d", &n);
vector<vector<int>> c(n - 1);
vector<vector<bool>> f(n, vector<bool>(n, 1));
for (int i = 0; i < n - 1; i++) {
c[i].resize(i + 1);
for (auto &e: c[i]) scanf("%d", &e);
for (int j = i / 2 + 1; j < i + 1; j++) f[i + 1][c[i][j]] = 0;
}
vector<int> ans(n); iota(ans.begin(), ans.end(), 0);
do {
bool ok = 1;
for (int i = 0; i < n; i++) {
if (i && !f[ans[i]][ans[i - 1]]) ok = 0;
if (i != n - 1 && !f[ans[i]][ans[i + 1]]) ok = 0;
}
if (ok) break;
} while (next_permutation(ans.begin(), ans.end()));
for (auto &e: ans) printf("%d ", e);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 11
Accepted
Test #1:
score: 11
Accepted
time: 0ms
memory: 3760kb
input:
2 0
output:
0 1
result:
ok correct
Test #2:
score: 11
Accepted
time: 1ms
memory: 3816kb
input:
99 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 10 9 8 7 6 5 4 3 2 1 0 11 10 9 8 7 6 5 4 3 2 1 0 12 11 10 9 8 7 6 5 4 3 2 1 0 13 12 11 10 9 8 7 6 5 4 3 2 1 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16 1...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
result:
ok correct
Test #3:
score: 11
Accepted
time: 23ms
memory: 5932kb
input:
1000 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 10 9 8 7 6 5 4 3 2 1 0 11 10 9 8 7 6 5 4 3 2 1 0 12 11 10 9 8 7 6 5 4 3 2 1 0 13 12 11 10 9 8 7 6 5 4 3 2 1 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok correct
Test #4:
score: 11
Accepted
time: 0ms
memory: 3768kb
input:
8 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0
output:
0 1 2 3 4 5 6 7
result:
ok correct
Test #5:
score: 11
Accepted
time: 0ms
memory: 3768kb
input:
6 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0
output:
0 1 2 3 4 5
result:
ok correct
Subtask #2:
score: 0
Time Limit Exceeded
Test #6:
score: 23
Accepted
time: 0ms
memory: 3768kb
input:
2 0
output:
0 1
result:
ok correct
Test #7:
score: 0
Time Limit Exceeded
input:
99 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 13 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 ...
output:
result:
Subtask #3:
score: 29
Accepted
Test #12:
score: 29
Accepted
time: 0ms
memory: 3760kb
input:
2 0
output:
0 1
result:
ok correct
Test #13:
score: 29
Accepted
time: 0ms
memory: 3720kb
input:
8 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0
output:
0 1 2 3 4 5 6 7
result:
ok correct
Test #14:
score: 29
Accepted
time: 1ms
memory: 3768kb
input:
8 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5 6
output:
3 7 0 4 1 5 2 6
result:
ok correct
Test #15:
score: 29
Accepted
time: 0ms
memory: 3856kb
input:
8 0 0 1 0 1 2 2 1 0 3 4 3 0 2 1 4 3 0 5 2 1 6 5 2 1 4 0 3
output:
0 1 3 5 4 2 7 6
result:
ok correct
Test #16:
score: 29
Accepted
time: 0ms
memory: 3768kb
input:
8 0 1 0 0 1 2 3 2 1 0 0 1 2 3 4 5 4 3 2 1 0 0 1 2 3 4 5 6
output:
0 1 2 5 6 4 3 7
result:
ok correct
Test #17:
score: 29
Accepted
time: 0ms
memory: 4052kb
input:
3 0 0 1
output:
1 0 2
result:
ok correct
Test #18:
score: 29
Accepted
time: 0ms
memory: 4052kb
input:
5 0 1 0 0 2 1 1 3 2 0
output:
0 1 2 3 4
result:
ok correct
Test #19:
score: 29
Accepted
time: 0ms
memory: 4052kb
input:
6 0 0 1 0 1 2 0 2 1 3 0 2 3 4 1
output:
0 1 3 5 2 4
result:
ok correct
Test #20:
score: 29
Accepted
time: 0ms
memory: 4048kb
input:
7 0 1 0 2 0 1 2 0 1 3 0 1 4 2 3 3 2 4 0 5 1
output:
0 1 2 3 6 4 5
result:
ok correct
Test #21:
score: 29
Accepted
time: 0ms
memory: 3768kb
input:
8 0 1 0 0 1 2 3 2 0 1 3 1 0 4 2 4 2 0 3 5 1 6 4 3 1 5 2 0
output:
0 1 2 4 6 7 3 5
result:
ok correct
Test #22:
score: 29
Accepted
time: 0ms
memory: 3844kb
input:
8 0 0 1 2 1 0 3 0 2 1 4 0 3 1 2 4 0 2 5 3 1 4 5 1 2 0 6 3
output:
0 1 3 2 6 4 5 7
result:
ok correct
Test #23:
score: 29
Accepted
time: 0ms
memory: 3764kb
input:
8 0 0 1 0 1 2 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0
output:
0 1 3 4 2 5 6 7
result:
ok correct
Test #24:
score: 29
Accepted
time: 1ms
memory: 3796kb
input:
8 0 1 0 2 1 0 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5 6
output:
3 7 0 4 1 5 2 6
result:
ok correct
Test #25:
score: 29
Accepted
time: 1ms
memory: 3768kb
input:
8 0 1 0 1 0 2 1 3 0 2 1 3 0 2 4 1 3 5 0 2 4 1 3 5 0 2 4 6
output:
0 7 5 6 3 4 1 2
result:
ok correct
Test #26:
score: 29
Accepted
time: 0ms
memory: 3772kb
input:
6 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0
output:
0 1 2 3 4 5
result:
ok correct
Test #27:
score: 29
Accepted
time: 0ms
memory: 3836kb
input:
5 0 0 1 0 1 2 0 1 2 3
output:
2 0 3 1 4
result:
ok correct
Test #28:
score: 29
Accepted
time: 0ms
memory: 3796kb
input:
4 0 1 0 0 2 1
output:
0 1 2 3
result:
ok correct
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%