# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98724 | 2019-02-25T11:59:39 Z | onjo0127 | Paths (BOI18_paths) | C++11 | 1347 ms | 23672 KB |
#include <bits/stdc++.h> using namespace std; vector<int> adj[300009]; int C[300009], D[300009][5]; int main() { long long a2 = 0, a3 = 0, a4 = 0, a5 = 0; int N, M, K; scanf("%d%d%d",&N,&M,&K); for(int i=1; i<=N; i++) {scanf("%d",&C[i]); --C[i];} for(int i=0; i<M; i++) { int u, v; scanf("%d%d",&u,&v); if(C[u] != C[v]) a2 += 2; adj[u].push_back(v); adj[v].push_back(u); } for(int i=1; i<=N; i++) for(auto& it: adj[i]) ++D[i][C[it]]; for(int i=1; i<=N; i++) { for(int a=0; a<5; a++) for(int b=0; b<5; b++) if(a != b && C[i] != a && C[i] != b) a3 += 1LL * D[i][a] * D[i][b]; for(auto& it: adj[i]) { if(C[i] == C[it]) continue; for(int a=0; a<5; a++) { for(int b=0; b<5; b++) { vector<int> X = {C[i], C[it], a, b}; sort(X.begin(), X.end()); if(X[0] != X[1] && X[1] != X[2] && X[2] != X[3]) a4 += 1LL * D[i][a] * D[it][b]; } } } if(K == 5) { vector<int> S; for(int a=0; a<5; a++) if(a != C[i]) S.push_back(a); do { long long a = 0, b = 0; for(auto& it: adj[i]) if(C[it] == S[0]) a += D[it][S[1]]; for(auto& it: adj[i]) if(C[it] == S[2]) b += D[it][S[3]]; a4 += a * b; } while(next_permutation(S.begin(), S.end())); } } printf("%lld", a2 + a3 + a4 + a5); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 7424 KB | Output is correct |
2 | Correct | 10 ms | 7424 KB | Output is correct |
3 | Correct | 9 ms | 7552 KB | Output is correct |
4 | Correct | 9 ms | 7424 KB | Output is correct |
5 | Correct | 10 ms | 7424 KB | Output is correct |
6 | Correct | 10 ms | 7424 KB | Output is correct |
7 | Correct | 9 ms | 7424 KB | Output is correct |
8 | Correct | 8 ms | 7424 KB | Output is correct |
9 | Correct | 9 ms | 7424 KB | Output is correct |
10 | Correct | 10 ms | 7424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 692 ms | 11212 KB | Output is correct |
2 | Correct | 655 ms | 11072 KB | Output is correct |
3 | Correct | 1099 ms | 22824 KB | Output is correct |
4 | Correct | 656 ms | 12536 KB | Output is correct |
5 | Correct | 194 ms | 12536 KB | Output is correct |
6 | Correct | 957 ms | 19308 KB | Output is correct |
7 | Correct | 1043 ms | 22904 KB | Output is correct |
8 | Correct | 1224 ms | 23544 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 7424 KB | Output is correct |
2 | Correct | 10 ms | 7424 KB | Output is correct |
3 | Correct | 9 ms | 7552 KB | Output is correct |
4 | Correct | 9 ms | 7424 KB | Output is correct |
5 | Correct | 10 ms | 7424 KB | Output is correct |
6 | Correct | 10 ms | 7424 KB | Output is correct |
7 | Correct | 9 ms | 7424 KB | Output is correct |
8 | Correct | 8 ms | 7424 KB | Output is correct |
9 | Correct | 9 ms | 7424 KB | Output is correct |
10 | Correct | 10 ms | 7424 KB | Output is correct |
11 | Correct | 692 ms | 11212 KB | Output is correct |
12 | Correct | 655 ms | 11072 KB | Output is correct |
13 | Correct | 1099 ms | 22824 KB | Output is correct |
14 | Correct | 656 ms | 12536 KB | Output is correct |
15 | Correct | 194 ms | 12536 KB | Output is correct |
16 | Correct | 957 ms | 19308 KB | Output is correct |
17 | Correct | 1043 ms | 22904 KB | Output is correct |
18 | Correct | 1224 ms | 23544 KB | Output is correct |
19 | Correct | 615 ms | 11172 KB | Output is correct |
20 | Correct | 568 ms | 11000 KB | Output is correct |
21 | Correct | 1127 ms | 22908 KB | Output is correct |
22 | Correct | 558 ms | 12664 KB | Output is correct |
23 | Correct | 194 ms | 12540 KB | Output is correct |
24 | Correct | 913 ms | 19376 KB | Output is correct |
25 | Correct | 1074 ms | 22864 KB | Output is correct |
26 | Correct | 1195 ms | 23672 KB | Output is correct |
27 | Correct | 643 ms | 10872 KB | Output is correct |
28 | Correct | 688 ms | 12016 KB | Output is correct |
29 | Correct | 1192 ms | 22828 KB | Output is correct |
30 | Correct | 1048 ms | 16836 KB | Output is correct |
31 | Correct | 1269 ms | 17036 KB | Output is correct |
32 | Correct | 1347 ms | 22904 KB | Output is correct |
33 | Correct | 9 ms | 7424 KB | Output is correct |
34 | Correct | 11 ms | 7424 KB | Output is correct |
35 | Correct | 11 ms | 7424 KB | Output is correct |
36 | Correct | 10 ms | 7424 KB | Output is correct |
37 | Correct | 11 ms | 7424 KB | Output is correct |
38 | Correct | 11 ms | 7424 KB | Output is correct |
39 | Correct | 10 ms | 7424 KB | Output is correct |
40 | Correct | 11 ms | 7424 KB | Output is correct |
41 | Correct | 10 ms | 7424 KB | Output is correct |
42 | Correct | 11 ms | 7424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 7424 KB | Output is correct |
2 | Correct | 288 ms | 8492 KB | Output is correct |
3 | Correct | 192 ms | 8568 KB | Output is correct |
4 | Correct | 380 ms | 12668 KB | Output is correct |
5 | Correct | 323 ms | 13292 KB | Output is correct |
6 | Correct | 478 ms | 12584 KB | Output is correct |
7 | Correct | 251 ms | 8540 KB | Output is correct |
8 | Correct | 375 ms | 12536 KB | Output is correct |
9 | Correct | 319 ms | 13420 KB | Output is correct |
10 | Correct | 424 ms | 13168 KB | Output is correct |
11 | Correct | 382 ms | 10356 KB | Output is correct |
12 | Correct | 440 ms | 11888 KB | Output is correct |
13 | Correct | 489 ms | 10608 KB | Output is correct |
14 | Correct | 523 ms | 12664 KB | Output is correct |
15 | Correct | 553 ms | 12792 KB | Output is correct |
16 | Correct | 9 ms | 7424 KB | Output is correct |
17 | Correct | 11 ms | 7424 KB | Output is correct |
18 | Correct | 8 ms | 7396 KB | Output is correct |
19 | Correct | 9 ms | 7424 KB | Output is correct |
20 | Correct | 11 ms | 7424 KB | Output is correct |
21 | Correct | 9 ms | 7424 KB | Output is correct |
22 | Correct | 9 ms | 7424 KB | Output is correct |
23 | Correct | 9 ms | 7424 KB | Output is correct |
24 | Correct | 8 ms | 7424 KB | Output is correct |
25 | Correct | 10 ms | 7424 KB | Output is correct |