# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1112782 | 2024-11-14T20:03:42 Z | kojac | Paths (BOI18_paths) | C++17 | 1075 ms | 941236 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll LINF = 0x3f3f3f3f3f3f3f3f; #define MAXN ((int)(3e5+2)) ll dp[MAXN][6][65], n, m, k, c[MAXN]; vector<ll> g[MAXN]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> k; for(int i = 1; i <= n; i++) cin >> c[i]; for(int i = 0; i < m; i++){ ll x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } for(int i = 1; i <= n; i++){ ll aux = (1<<c[i]); dp[i][1][aux] = 1; } for(int i = 2; i <= k; i++){ for(int j = 1; j <= n; j++){ for(int bm = 0; bm < (1<<(k+1)); bm++){ if((bm & (1<<c[j])) == 0) continue; ll aux = bm-(1<<c[j]); for(int x = 0; x < g[j].size(); x++){ dp[j][i][bm] += dp[g[j][x]][i-1][aux]; } } } } ll ans = 0; for(int i = 2; i <= k; i++){ for(int j = 1; j <= n; j++){ for(int aux = 0; aux < (1<<(k+1)); aux++){ ans += dp[j][i][aux]; } } } // cout << dp[1][3][6] << " AQQ\n"; cout << ans << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10832 KB | Output is correct |
2 | Correct | 2 ms | 10832 KB | Output is correct |
3 | Correct | 3 ms | 10676 KB | Output is correct |
4 | Correct | 3 ms | 10832 KB | Output is correct |
5 | Correct | 2 ms | 10832 KB | Output is correct |
6 | Correct | 2 ms | 10832 KB | Output is correct |
7 | Correct | 3 ms | 10832 KB | Output is correct |
8 | Correct | 2 ms | 10832 KB | Output is correct |
9 | Correct | 2 ms | 10832 KB | Output is correct |
10 | Correct | 2 ms | 10832 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 32400 KB | Output is correct |
2 | Correct | 42 ms | 20040 KB | Output is correct |
3 | Correct | 800 ms | 940616 KB | Output is correct |
4 | Correct | 114 ms | 112712 KB | Output is correct |
5 | Correct | 108 ms | 112808 KB | Output is correct |
6 | Correct | 552 ms | 633796 KB | Output is correct |
7 | Correct | 813 ms | 940616 KB | Output is correct |
8 | Correct | 835 ms | 941236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10832 KB | Output is correct |
2 | Correct | 2 ms | 10832 KB | Output is correct |
3 | Correct | 3 ms | 10676 KB | Output is correct |
4 | Correct | 3 ms | 10832 KB | Output is correct |
5 | Correct | 2 ms | 10832 KB | Output is correct |
6 | Correct | 2 ms | 10832 KB | Output is correct |
7 | Correct | 3 ms | 10832 KB | Output is correct |
8 | Correct | 2 ms | 10832 KB | Output is correct |
9 | Correct | 2 ms | 10832 KB | Output is correct |
10 | Correct | 2 ms | 10832 KB | Output is correct |
11 | Correct | 53 ms | 32400 KB | Output is correct |
12 | Correct | 42 ms | 20040 KB | Output is correct |
13 | Correct | 800 ms | 940616 KB | Output is correct |
14 | Correct | 114 ms | 112712 KB | Output is correct |
15 | Correct | 108 ms | 112808 KB | Output is correct |
16 | Correct | 552 ms | 633796 KB | Output is correct |
17 | Correct | 813 ms | 940616 KB | Output is correct |
18 | Correct | 835 ms | 941236 KB | Output is correct |
19 | Correct | 61 ms | 35144 KB | Output is correct |
20 | Correct | 48 ms | 22364 KB | Output is correct |
21 | Correct | 831 ms | 940668 KB | Output is correct |
22 | Correct | 114 ms | 112712 KB | Output is correct |
23 | Correct | 101 ms | 112660 KB | Output is correct |
24 | Correct | 566 ms | 633792 KB | Output is correct |
25 | Correct | 799 ms | 940696 KB | Output is correct |
26 | Correct | 783 ms | 941128 KB | Output is correct |
27 | Correct | 65 ms | 22256 KB | Output is correct |
28 | Correct | 92 ms | 45492 KB | Output is correct |
29 | Correct | 946 ms | 940544 KB | Output is correct |
30 | Correct | 568 ms | 481284 KB | Output is correct |
31 | Correct | 608 ms | 480624 KB | Output is correct |
32 | Correct | 1075 ms | 940708 KB | Output is correct |
33 | Correct | 3 ms | 10832 KB | Output is correct |
34 | Correct | 3 ms | 10832 KB | Output is correct |
35 | Correct | 3 ms | 10832 KB | Output is correct |
36 | Correct | 3 ms | 10832 KB | Output is correct |
37 | Correct | 2 ms | 10908 KB | Output is correct |
38 | Correct | 3 ms | 10844 KB | Output is correct |
39 | Correct | 3 ms | 10832 KB | Output is correct |
40 | Correct | 3 ms | 10832 KB | Output is correct |
41 | Correct | 3 ms | 10832 KB | Output is correct |
42 | Correct | 2 ms | 10832 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 10832 KB | Output is correct |
2 | Correct | 47 ms | 15092 KB | Output is correct |
3 | Correct | 17 ms | 14928 KB | Output is correct |
4 | Correct | 268 ms | 318600 KB | Output is correct |
5 | Correct | 270 ms | 318020 KB | Output is correct |
6 | Correct | 481 ms | 317000 KB | Output is correct |
7 | Correct | 26 ms | 11088 KB | Output is correct |
8 | Correct | 333 ms | 317076 KB | Output is correct |
9 | Correct | 309 ms | 318916 KB | Output is correct |
10 | Correct | 328 ms | 318696 KB | Output is correct |
11 | Correct | 243 ms | 165056 KB | Output is correct |
12 | Correct | 339 ms | 241800 KB | Output is correct |
13 | Correct | 241 ms | 165188 KB | Output is correct |
14 | Correct | 410 ms | 318612 KB | Output is correct |
15 | Correct | 457 ms | 317040 KB | Output is correct |
16 | Correct | 3 ms | 10832 KB | Output is correct |
17 | Correct | 3 ms | 10832 KB | Output is correct |
18 | Correct | 4 ms | 10832 KB | Output is correct |
19 | Correct | 3 ms | 10868 KB | Output is correct |
20 | Correct | 2 ms | 10832 KB | Output is correct |
21 | Correct | 3 ms | 10832 KB | Output is correct |
22 | Correct | 3 ms | 10832 KB | Output is correct |
23 | Correct | 3 ms | 10832 KB | Output is correct |
24 | Correct | 2 ms | 8784 KB | Output is correct |
25 | Correct | 6 ms | 7504 KB | Output is correct |