# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
202432 | 2020-02-16T05:10:03 Z | quocnguyen1012 | Paths (BOI18_paths) | C++14 | 486 ms | 59768 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; const int maxn = 3e5 + 5; const ll llinf = 1e18; bool testbit(int x, int n) { return x >> n & 1; } int addbit(int x, int n) { return x + (1 << n); } int delbit(int x, int n) { return x - (1 << n); } int f[maxn][1 << 5]; int col[maxn]; vector<int> adj[maxn]; int N, K, M; int solve(int u, int mask) { int & res = f[u][mask]; if (res != -1) return res; res = 1; for (int v : adj[u]){ if (testbit(mask, col[v]) == 0){ res += solve(v, addbit(mask, col[v])); } } return res; } signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("A.INP", "r")){ freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); } cin >> N >> M >> K; for (int i = 1; i <= N; ++i){ cin >> col[i]; --col[i]; } while (M--){ int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } memset(f, -1, sizeof f); ll res = 0; for (int i = 1; i <= N; ++i){ res += solve(i, (1 << col[i])); } cout << res - N; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 44920 KB | Output is correct |
2 | Correct | 27 ms | 44920 KB | Output is correct |
3 | Correct | 28 ms | 45048 KB | Output is correct |
4 | Correct | 30 ms | 45048 KB | Output is correct |
5 | Correct | 28 ms | 45048 KB | Output is correct |
6 | Correct | 29 ms | 44920 KB | Output is correct |
7 | Correct | 28 ms | 45048 KB | Output is correct |
8 | Correct | 30 ms | 44920 KB | Output is correct |
9 | Correct | 27 ms | 44920 KB | Output is correct |
10 | Correct | 30 ms | 44920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 105 ms | 51528 KB | Output is correct |
2 | Correct | 89 ms | 50680 KB | Output is correct |
3 | Correct | 412 ms | 59128 KB | Output is correct |
4 | Correct | 156 ms | 52896 KB | Output is correct |
5 | Correct | 143 ms | 52856 KB | Output is correct |
6 | Correct | 292 ms | 56940 KB | Output is correct |
7 | Correct | 412 ms | 59256 KB | Output is correct |
8 | Correct | 397 ms | 59672 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 44920 KB | Output is correct |
2 | Correct | 27 ms | 44920 KB | Output is correct |
3 | Correct | 28 ms | 45048 KB | Output is correct |
4 | Correct | 30 ms | 45048 KB | Output is correct |
5 | Correct | 28 ms | 45048 KB | Output is correct |
6 | Correct | 29 ms | 44920 KB | Output is correct |
7 | Correct | 28 ms | 45048 KB | Output is correct |
8 | Correct | 30 ms | 44920 KB | Output is correct |
9 | Correct | 27 ms | 44920 KB | Output is correct |
10 | Correct | 30 ms | 44920 KB | Output is correct |
11 | Correct | 105 ms | 51528 KB | Output is correct |
12 | Correct | 89 ms | 50680 KB | Output is correct |
13 | Correct | 412 ms | 59128 KB | Output is correct |
14 | Correct | 156 ms | 52896 KB | Output is correct |
15 | Correct | 143 ms | 52856 KB | Output is correct |
16 | Correct | 292 ms | 56940 KB | Output is correct |
17 | Correct | 412 ms | 59256 KB | Output is correct |
18 | Correct | 397 ms | 59672 KB | Output is correct |
19 | Correct | 118 ms | 51448 KB | Output is correct |
20 | Correct | 114 ms | 50680 KB | Output is correct |
21 | Correct | 420 ms | 59128 KB | Output is correct |
22 | Correct | 153 ms | 52856 KB | Output is correct |
23 | Correct | 142 ms | 52856 KB | Output is correct |
24 | Correct | 300 ms | 57144 KB | Output is correct |
25 | Correct | 401 ms | 59084 KB | Output is correct |
26 | Correct | 401 ms | 59768 KB | Output is correct |
27 | Correct | 118 ms | 50680 KB | Output is correct |
28 | Correct | 148 ms | 52276 KB | Output is correct |
29 | Correct | 486 ms | 58932 KB | Output is correct |
30 | Correct | 372 ms | 55452 KB | Output is correct |
31 | Correct | 398 ms | 55540 KB | Output is correct |
32 | Correct | 470 ms | 59256 KB | Output is correct |
33 | Correct | 32 ms | 44920 KB | Output is correct |
34 | Correct | 32 ms | 44920 KB | Output is correct |
35 | Correct | 31 ms | 44920 KB | Output is correct |
36 | Correct | 32 ms | 45048 KB | Output is correct |
37 | Correct | 31 ms | 44920 KB | Output is correct |
38 | Correct | 32 ms | 45048 KB | Output is correct |
39 | Correct | 32 ms | 44920 KB | Output is correct |
40 | Correct | 32 ms | 45048 KB | Output is correct |
41 | Correct | 31 ms | 44920 KB | Output is correct |
42 | Correct | 32 ms | 44920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 44920 KB | Output is correct |
2 | Correct | 68 ms | 46816 KB | Output is correct |
3 | Correct | 54 ms | 46712 KB | Output is correct |
4 | Correct | 116 ms | 49528 KB | Output is correct |
5 | Correct | 91 ms | 50288 KB | Output is correct |
6 | Correct | 163 ms | 49528 KB | Output is correct |
7 | Correct | 57 ms | 46840 KB | Output is correct |
8 | Correct | 139 ms | 49528 KB | Output is correct |
9 | Correct | 101 ms | 50288 KB | Output is correct |
10 | Correct | 129 ms | 50160 KB | Output is correct |
11 | Correct | 123 ms | 48244 KB | Output is correct |
12 | Correct | 97 ms | 49328 KB | Output is correct |
13 | Correct | 138 ms | 48368 KB | Output is correct |
14 | Correct | 164 ms | 49656 KB | Output is correct |
15 | Correct | 134 ms | 49656 KB | Output is correct |
16 | Correct | 29 ms | 44920 KB | Output is correct |
17 | Correct | 31 ms | 44920 KB | Output is correct |
18 | Correct | 33 ms | 45048 KB | Output is correct |
19 | Correct | 31 ms | 44920 KB | Output is correct |
20 | Correct | 31 ms | 45128 KB | Output is correct |
21 | Correct | 31 ms | 44920 KB | Output is correct |
22 | Correct | 30 ms | 45024 KB | Output is correct |
23 | Correct | 31 ms | 44920 KB | Output is correct |
24 | Correct | 31 ms | 45048 KB | Output is correct |
25 | Correct | 30 ms | 44920 KB | Output is correct |