# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
286271 | 2020-08-30T08:58:53 Z | spdskatr | Village (BOI20_village) | C++14 | 71 ms | 384 KB |
#include <cstdio> #include <cstdlib> #include <algorithm> #include <cassert> using namespace std; int N; int adj[15][15], p[15]; int minval = 2069696969, mina[15]; int maxval = 0, maxa[15]; int main() { scanf("%d", &N); assert(N <= 10); for (int i = 1; i <= N; i++) for (int j = i+1; j <= N; j++) adj[i][j] = adj[j][i] = 69; for (int i = 0; i < N-1; i++) { int a, b; scanf("%d %d", &a, &b); adj[a][b] = adj[b][a] = 1; } for (int m = 1; m <= N; m++) for (int u = 1; u <= N; u++) for (int v = 1; v <= N; v++) adj[u][v] = min(adj[u][v], adj[u][m] + adj[m][v]); for (int i = 1; i <= N; i++) p[i-1] = i; do { int val = 0, rip = 0; for (int i = 1; i <= N; i++) if (p[i-1] == i) { rip = 1; } if (rip) continue; for (int i = 1; i <= N; i++) val += adj[i][p[i-1]]; if (val > maxval) { maxval = val; for (int i = 0; i < N; i++) maxa[i] = p[i]; } if (val < minval) { minval = val; for (int i = 0; i < N; i++) mina[i] = p[i]; } } while (next_permutation(p, p+N)); printf("%d %d\n", minval, maxval); for (int i = 0; i < N; i++) { if (i == 0) printf("%d", mina[i]); else printf(" %d", mina[i]); } printf("\n"); for (int i = 0; i < N; i++) { if (i == 0) printf("%d", maxa[i]); else printf(" %d", maxa[i]); } printf("\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 7 ms | 256 KB | Output is correct |
10 | Correct | 69 ms | 256 KB | Output is correct |
11 | Correct | 67 ms | 256 KB | Output is correct |
12 | Correct | 69 ms | 256 KB | Output is correct |
13 | Correct | 71 ms | 256 KB | Output is correct |
14 | Correct | 67 ms | 256 KB | Output is correct |
15 | Correct | 68 ms | 256 KB | Output is correct |
16 | Correct | 67 ms | 344 KB | Output is correct |
17 | Correct | 70 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 7 ms | 256 KB | Output is correct |
10 | Correct | 69 ms | 256 KB | Output is correct |
11 | Correct | 67 ms | 256 KB | Output is correct |
12 | Correct | 69 ms | 256 KB | Output is correct |
13 | Correct | 71 ms | 256 KB | Output is correct |
14 | Correct | 67 ms | 256 KB | Output is correct |
15 | Correct | 68 ms | 256 KB | Output is correct |
16 | Correct | 67 ms | 344 KB | Output is correct |
17 | Correct | 70 ms | 256 KB | Output is correct |
18 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 |
19 | Halted | 0 ms | 0 KB | - |