Submission #716434

# Submission time Handle Problem Language Result Execution time Memory
716434 2023-03-30T05:53:11 Z KING Paths (BOI18_paths) C++14
100 / 100
324 ms 53360 KB
#include<bits/stdc++.h>
#define NOT_STONKS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
const int maxn = 3e5 + 10; //4e6 + 10; //3e5 + 10;
const int mod = 1e9 + 7; //998244353;
typedef long long ll;

ll n, m, k, c[maxn], dp[50][maxn];
vector<int> G[maxn];

int main() {
    NOT_STONKS;

    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> c[i], c[i]--;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    for (int i = 1; i <= n; i++) dp[1 << c[i]][i] = 1;
    for (int mask = 1; mask < (1 << k); mask++)
        for (int i = 1; i <= n; i++) 
            for (int u : G[i]) 
                dp[mask][i] += dp[mask ^ (1 << c[i])][u];

    ll ans = 0;
    for (int mask = 0; mask < (1 << k); mask++) 
        for (int i = 1; i <= n; i++) if (__builtin_popcount(mask) > 1)
            ans += dp[mask][i];
    
    cout << ans << endl;
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 4 ms 7508 KB Output is correct
2 Correct 4 ms 7508 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 7292 KB Output is correct
6 Correct 5 ms 7508 KB Output is correct
7 Correct 4 ms 7508 KB Output is correct
8 Correct 4 ms 7508 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 11284 KB Output is correct
2 Correct 57 ms 10988 KB Output is correct
3 Correct 262 ms 34472 KB Output is correct
4 Correct 86 ms 12636 KB Output is correct
5 Correct 78 ms 12272 KB Output is correct
6 Correct 182 ms 26960 KB Output is correct
7 Correct 236 ms 34472 KB Output is correct
8 Correct 232 ms 35152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7508 KB Output is correct
2 Correct 4 ms 7508 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 7292 KB Output is correct
6 Correct 5 ms 7508 KB Output is correct
7 Correct 4 ms 7508 KB Output is correct
8 Correct 4 ms 7508 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 58 ms 11284 KB Output is correct
12 Correct 57 ms 10988 KB Output is correct
13 Correct 262 ms 34472 KB Output is correct
14 Correct 86 ms 12636 KB Output is correct
15 Correct 78 ms 12272 KB Output is correct
16 Correct 182 ms 26960 KB Output is correct
17 Correct 236 ms 34472 KB Output is correct
18 Correct 232 ms 35152 KB Output is correct
19 Correct 60 ms 11288 KB Output is correct
20 Correct 50 ms 10996 KB Output is correct
21 Correct 235 ms 34416 KB Output is correct
22 Correct 80 ms 12620 KB Output is correct
23 Correct 82 ms 12180 KB Output is correct
24 Correct 181 ms 26976 KB Output is correct
25 Correct 259 ms 34440 KB Output is correct
26 Correct 233 ms 35088 KB Output is correct
27 Correct 55 ms 11188 KB Output is correct
28 Correct 80 ms 12828 KB Output is correct
29 Correct 324 ms 53260 KB Output is correct
30 Correct 216 ms 31968 KB Output is correct
31 Correct 258 ms 32128 KB Output is correct
32 Correct 313 ms 53360 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7508 KB Output is correct
35 Correct 5 ms 7380 KB Output is correct
36 Correct 5 ms 7380 KB Output is correct
37 Correct 4 ms 7380 KB Output is correct
38 Correct 4 ms 7508 KB Output is correct
39 Correct 4 ms 7508 KB Output is correct
40 Correct 4 ms 7508 KB Output is correct
41 Correct 5 ms 7380 KB Output is correct
42 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7508 KB Output is correct
2 Correct 22 ms 8880 KB Output is correct
3 Correct 20 ms 8540 KB Output is correct
4 Correct 58 ms 16372 KB Output is correct
5 Correct 44 ms 17208 KB Output is correct
6 Correct 140 ms 35352 KB Output is correct
7 Correct 19 ms 8660 KB Output is correct
8 Correct 71 ms 22748 KB Output is correct
9 Correct 58 ms 23492 KB Output is correct
10 Correct 76 ms 23372 KB Output is correct
11 Correct 69 ms 21840 KB Output is correct
12 Correct 70 ms 29100 KB Output is correct
13 Correct 61 ms 22000 KB Output is correct
14 Correct 121 ms 35352 KB Output is correct
15 Correct 127 ms 35488 KB Output is correct
16 Correct 4 ms 7508 KB Output is correct
17 Correct 4 ms 7508 KB Output is correct
18 Correct 4 ms 7380 KB Output is correct
19 Correct 5 ms 7380 KB Output is correct
20 Correct 4 ms 7388 KB Output is correct
21 Correct 4 ms 7508 KB Output is correct
22 Correct 5 ms 7508 KB Output is correct
23 Correct 4 ms 7508 KB Output is correct
24 Correct 4 ms 7380 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct