답안 #707720

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707720 2023-03-09T20:04:08 Z stevancv Paths (BOI18_paths) C++14
100 / 100
343 ms 97232 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 3e5 + 5;
const int inf = 2e9;
const int mod = 1e9 + 7;
vector<int> g[N];
ll dp[N][32];
int a[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= 1;
        dp[i][1 << a[i]] = 1;
    }
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u -= 1; v -= 1;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    ll ans = 0;
    for (int mask = 0; mask < (1 << k); mask++) {
        for (int i = 0; i < n; i++) {
            if ((mask & (1 << a[i])) == 0) continue;
            for (int j : g[i]) {
                if ((mask & (1 << a[j])) == 0) continue;
                dp[i][mask] += dp[j][mask ^ (1 << a[i])];
            }
            ans += dp[i][mask];
        }
    }
    cout << ans - n << en;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7380 KB Output is correct
6 Correct 4 ms 7364 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 4 ms 7372 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 15064 KB Output is correct
2 Correct 64 ms 13340 KB Output is correct
3 Correct 258 ms 96528 KB Output is correct
4 Correct 104 ms 22732 KB Output is correct
5 Correct 95 ms 22724 KB Output is correct
6 Correct 220 ms 69372 KB Output is correct
7 Correct 270 ms 96520 KB Output is correct
8 Correct 262 ms 97232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7380 KB Output is correct
6 Correct 4 ms 7364 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 4 ms 7372 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 72 ms 15064 KB Output is correct
12 Correct 64 ms 13340 KB Output is correct
13 Correct 258 ms 96528 KB Output is correct
14 Correct 104 ms 22732 KB Output is correct
15 Correct 95 ms 22724 KB Output is correct
16 Correct 220 ms 69372 KB Output is correct
17 Correct 270 ms 96520 KB Output is correct
18 Correct 262 ms 97232 KB Output is correct
19 Correct 67 ms 15008 KB Output is correct
20 Correct 54 ms 13380 KB Output is correct
21 Correct 256 ms 96508 KB Output is correct
22 Correct 96 ms 22672 KB Output is correct
23 Correct 88 ms 22796 KB Output is correct
24 Correct 180 ms 69436 KB Output is correct
25 Correct 252 ms 96524 KB Output is correct
26 Correct 272 ms 97176 KB Output is correct
27 Correct 63 ms 13424 KB Output is correct
28 Correct 88 ms 16660 KB Output is correct
29 Correct 335 ms 96408 KB Output is correct
30 Correct 209 ms 55360 KB Output is correct
31 Correct 288 ms 55388 KB Output is correct
32 Correct 343 ms 96624 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7380 KB Output is correct
35 Correct 4 ms 7380 KB Output is correct
36 Correct 6 ms 7380 KB Output is correct
37 Correct 4 ms 7372 KB Output is correct
38 Correct 4 ms 7380 KB Output is correct
39 Correct 6 ms 7380 KB Output is correct
40 Correct 5 ms 7380 KB Output is correct
41 Correct 4 ms 7380 KB Output is correct
42 Correct 4 ms 7380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 31 ms 9324 KB Output is correct
3 Correct 21 ms 9228 KB Output is correct
4 Correct 72 ms 36852 KB Output is correct
5 Correct 55 ms 37664 KB Output is correct
6 Correct 154 ms 36960 KB Output is correct
7 Correct 27 ms 9304 KB Output is correct
8 Correct 87 ms 36888 KB Output is correct
9 Correct 66 ms 37648 KB Output is correct
10 Correct 77 ms 37704 KB Output is correct
11 Correct 78 ms 22984 KB Output is correct
12 Correct 77 ms 30424 KB Output is correct
13 Correct 74 ms 23156 KB Output is correct
14 Correct 136 ms 36944 KB Output is correct
15 Correct 143 ms 37052 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 4 ms 7372 KB Output is correct
18 Correct 4 ms 7380 KB Output is correct
19 Correct 4 ms 7380 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
21 Correct 4 ms 7408 KB Output is correct
22 Correct 4 ms 7380 KB Output is correct
23 Correct 4 ms 7380 KB Output is correct
24 Correct 4 ms 7376 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct