# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
62820 | 2018-07-30T08:32:52 Z | SpaimaCarpatilor | Paths (BOI18_paths) | C++17 | 688 ms | 102932 KB |
#include<bits/stdc++.h> using namespace std; int N, M, K, c[300009]; long long *dp[32]; vector < int > v[300009]; int main () { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d %d %d", &N, &M, &K); for (int i=1; i<=N; i++) scanf ("%d", &c[i]), c[i] --; while (M --) { int x, y; scanf ("%d %d", &x, &y); v[x].push_back (y); v[y].push_back (x); } for (int i=0; i<(1 << K); i++) dp[i] = new long long[N + 1] (); long long ans = 0; for (int msk = 1; msk < (1 << K); msk ++) for (int i=1; i<=N; i++) if ((msk >> c[i]) & 1) { if (msk == (1 << c[i])) dp[msk][i] = 1; else { for (auto j : v[i]) dp[msk][i] += dp[msk ^ (1 << c[i])][j]; } ans += dp[msk][i]; /* if (dp[msk][i] > 0) printf ("(%d, %d) -> %lld\n", msk, i, dp[msk][i]);*/ } printf ("%lld\n", ans - N); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 7312 KB | Output is correct |
2 | Correct | 10 ms | 7400 KB | Output is correct |
3 | Correct | 10 ms | 7608 KB | Output is correct |
4 | Correct | 9 ms | 7632 KB | Output is correct |
5 | Correct | 10 ms | 7692 KB | Output is correct |
6 | Correct | 9 ms | 7704 KB | Output is correct |
7 | Correct | 9 ms | 7704 KB | Output is correct |
8 | Correct | 9 ms | 7704 KB | Output is correct |
9 | Correct | 12 ms | 7704 KB | Output is correct |
10 | Correct | 10 ms | 7704 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 136 ms | 14372 KB | Output is correct |
2 | Correct | 96 ms | 16288 KB | Output is correct |
3 | Correct | 448 ms | 45668 KB | Output is correct |
4 | Correct | 215 ms | 45668 KB | Output is correct |
5 | Correct | 280 ms | 45668 KB | Output is correct |
6 | Correct | 376 ms | 48556 KB | Output is correct |
7 | Correct | 496 ms | 60824 KB | Output is correct |
8 | Correct | 473 ms | 66100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 7312 KB | Output is correct |
2 | Correct | 10 ms | 7400 KB | Output is correct |
3 | Correct | 10 ms | 7608 KB | Output is correct |
4 | Correct | 9 ms | 7632 KB | Output is correct |
5 | Correct | 10 ms | 7692 KB | Output is correct |
6 | Correct | 9 ms | 7704 KB | Output is correct |
7 | Correct | 9 ms | 7704 KB | Output is correct |
8 | Correct | 9 ms | 7704 KB | Output is correct |
9 | Correct | 12 ms | 7704 KB | Output is correct |
10 | Correct | 10 ms | 7704 KB | Output is correct |
11 | Correct | 136 ms | 14372 KB | Output is correct |
12 | Correct | 96 ms | 16288 KB | Output is correct |
13 | Correct | 448 ms | 45668 KB | Output is correct |
14 | Correct | 215 ms | 45668 KB | Output is correct |
15 | Correct | 280 ms | 45668 KB | Output is correct |
16 | Correct | 376 ms | 48556 KB | Output is correct |
17 | Correct | 496 ms | 60824 KB | Output is correct |
18 | Correct | 473 ms | 66100 KB | Output is correct |
19 | Correct | 181 ms | 66100 KB | Output is correct |
20 | Correct | 96 ms | 66100 KB | Output is correct |
21 | Correct | 464 ms | 74968 KB | Output is correct |
22 | Correct | 234 ms | 74968 KB | Output is correct |
23 | Correct | 226 ms | 74968 KB | Output is correct |
24 | Correct | 365 ms | 76144 KB | Output is correct |
25 | Correct | 514 ms | 84336 KB | Output is correct |
26 | Correct | 474 ms | 84972 KB | Output is correct |
27 | Correct | 151 ms | 84972 KB | Output is correct |
28 | Correct | 194 ms | 84972 KB | Output is correct |
29 | Correct | 549 ms | 102836 KB | Output is correct |
30 | Correct | 507 ms | 102836 KB | Output is correct |
31 | Correct | 440 ms | 102836 KB | Output is correct |
32 | Correct | 688 ms | 102932 KB | Output is correct |
33 | Correct | 9 ms | 102932 KB | Output is correct |
34 | Correct | 9 ms | 102932 KB | Output is correct |
35 | Correct | 9 ms | 102932 KB | Output is correct |
36 | Correct | 9 ms | 102932 KB | Output is correct |
37 | Correct | 10 ms | 102932 KB | Output is correct |
38 | Correct | 9 ms | 102932 KB | Output is correct |
39 | Correct | 10 ms | 102932 KB | Output is correct |
40 | Correct | 10 ms | 102932 KB | Output is correct |
41 | Correct | 12 ms | 102932 KB | Output is correct |
42 | Correct | 10 ms | 102932 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 102932 KB | Output is correct |
2 | Correct | 44 ms | 102932 KB | Output is correct |
3 | Correct | 42 ms | 102932 KB | Output is correct |
4 | Correct | 155 ms | 102932 KB | Output is correct |
5 | Correct | 113 ms | 102932 KB | Output is correct |
6 | Correct | 290 ms | 102932 KB | Output is correct |
7 | Correct | 53 ms | 102932 KB | Output is correct |
8 | Correct | 191 ms | 102932 KB | Output is correct |
9 | Correct | 168 ms | 102932 KB | Output is correct |
10 | Correct | 193 ms | 102932 KB | Output is correct |
11 | Correct | 174 ms | 102932 KB | Output is correct |
12 | Correct | 170 ms | 102932 KB | Output is correct |
13 | Correct | 158 ms | 102932 KB | Output is correct |
14 | Correct | 290 ms | 102932 KB | Output is correct |
15 | Correct | 316 ms | 102932 KB | Output is correct |
16 | Correct | 9 ms | 102932 KB | Output is correct |
17 | Correct | 11 ms | 102932 KB | Output is correct |
18 | Correct | 10 ms | 102932 KB | Output is correct |
19 | Correct | 10 ms | 102932 KB | Output is correct |
20 | Correct | 11 ms | 102932 KB | Output is correct |
21 | Correct | 11 ms | 102932 KB | Output is correct |
22 | Correct | 10 ms | 102932 KB | Output is correct |
23 | Correct | 9 ms | 102932 KB | Output is correct |
24 | Correct | 10 ms | 102932 KB | Output is correct |
25 | Correct | 9 ms | 102932 KB | Output is correct |