# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
547397 | 2022-04-10T15:31:56 Z | Olympia | Paths (BOI18_paths) | C++17 | 1587 ms | 375032 KB |
#include <cmath> #include <iostream> #include <set> #include <climits> #include <algorithm> #include <cassert> #include <vector> #include <iomanip> #include <type_traits> #include <string> #include <queue> #include <map> #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") using namespace std; vector<vector<int>> adj; vector<int> color; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M, K; cin >> N >> M >> K; adj.resize(32 * N), color.resize(N); for (int i = 0; i < N; i++) { cin >> color[i]; color[i]--; } for (int i = 0; i < M; i++) { int u, v; cin >> u >> v; u--, v--; for (int mask_u = 0; mask_u < 32; mask_u++) { if (mask_u & (1 << color[u]) && !(mask_u & (1 << color[v]))) { adj[mask_u * N + u].push_back((mask_u ^ (1 << color[v])) * N + v); } } for (int mask_v = 0; mask_v < 32; mask_v++) { if (mask_v & (1 << color[v]) && !(mask_v & (1 << color[u]))) { adj[mask_v * N + v].push_back((mask_v ^ (1 << color[u])) * N + u); } } } vector<int64_t> dp; dp.assign(32 * N , 0); for (int i = 0; i < N; i++) { dp[N * (1 << color[i]) + i] = 1; } for (int bits = 0; bits <= 5; bits++) { for (int mask = 0; mask < 32; mask++) { if (__builtin_popcount(mask) != bits) { continue; } for (int j = 0; j < N; j++) { for (int k: adj[mask * N + j]) { dp[k] += dp[mask * N + j]; } } } } int64_t ans = 0; for (int i = 0; i < dp.size(); i++) { ans += dp[i]; } cout << ans - N << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 308 ms | 26852 KB | Output is correct |
2 | Correct | 137 ms | 17380 KB | Output is correct |
3 | Correct | 1418 ms | 366584 KB | Output is correct |
4 | Correct | 474 ms | 48508 KB | Output is correct |
5 | Correct | 87 ms | 30536 KB | Output is correct |
6 | Correct | 1121 ms | 253140 KB | Output is correct |
7 | Correct | 1258 ms | 366652 KB | Output is correct |
8 | Correct | 1450 ms | 373096 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 308 ms | 26852 KB | Output is correct |
12 | Correct | 137 ms | 17380 KB | Output is correct |
13 | Correct | 1418 ms | 366584 KB | Output is correct |
14 | Correct | 474 ms | 48508 KB | Output is correct |
15 | Correct | 87 ms | 30536 KB | Output is correct |
16 | Correct | 1121 ms | 253140 KB | Output is correct |
17 | Correct | 1258 ms | 366652 KB | Output is correct |
18 | Correct | 1450 ms | 373096 KB | Output is correct |
19 | Correct | 343 ms | 26828 KB | Output is correct |
20 | Correct | 158 ms | 17272 KB | Output is correct |
21 | Correct | 1278 ms | 366712 KB | Output is correct |
22 | Correct | 455 ms | 48440 KB | Output is correct |
23 | Correct | 81 ms | 30540 KB | Output is correct |
24 | Correct | 1144 ms | 253144 KB | Output is correct |
25 | Correct | 1333 ms | 366796 KB | Output is correct |
26 | Correct | 1317 ms | 373160 KB | Output is correct |
27 | Correct | 175 ms | 23744 KB | Output is correct |
28 | Correct | 531 ms | 32552 KB | Output is correct |
29 | Correct | 1587 ms | 374764 KB | Output is correct |
30 | Correct | 1259 ms | 202628 KB | Output is correct |
31 | Correct | 1318 ms | 208976 KB | Output is correct |
32 | Correct | 1509 ms | 375032 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 0 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 340 KB | Output is correct |
38 | Correct | 1 ms | 340 KB | Output is correct |
39 | Correct | 1 ms | 340 KB | Output is correct |
40 | Correct | 1 ms | 340 KB | Output is correct |
41 | Correct | 0 ms | 212 KB | Output is correct |
42 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 76 ms | 9936 KB | Output is correct |
3 | Correct | 47 ms | 9572 KB | Output is correct |
4 | Correct | 428 ms | 123736 KB | Output is correct |
5 | Correct | 353 ms | 121200 KB | Output is correct |
6 | Correct | 505 ms | 127964 KB | Output is correct |
7 | Correct | 50 ms | 8344 KB | Output is correct |
8 | Correct | 482 ms | 126456 KB | Output is correct |
9 | Correct | 383 ms | 123512 KB | Output is correct |
10 | Correct | 577 ms | 133612 KB | Output is correct |
11 | Correct | 372 ms | 68936 KB | Output is correct |
12 | Correct | 399 ms | 102460 KB | Output is correct |
13 | Correct | 409 ms | 72648 KB | Output is correct |
14 | Correct | 495 ms | 128124 KB | Output is correct |
15 | Correct | 517 ms | 129364 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 320 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 320 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 324 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |