Submission #716556

# Submission time Handle Problem Language Result Execution time Memory
716556 2023-03-30T10:01:23 Z AranMaster Paths (BOI18_paths) C++17
53 / 100
179 ms 31328 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector <int> adj[maxn];
int dp[maxn][1 << 5];
int c[maxn];
int n, m , k;
int main(){
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++){
        cin >> c[i];
        c[i]--;
        dp[i][1 << c[i]] = 1;
    }

    for(int i = 1; i <= m; i++){
        int a, b; 
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    long long ans = 0;
    for(int mask = 1; mask < (1 << 5); mask++){
        if(__builtin_popcount(mask) == 1) continue;
        for(int i = 1; i <= n; i++){
            if(mask & (1 << c[i])){
                for(int u : adj[i]){
                    dp[i][mask] += dp[u][mask ^ (1 << c[i])];
                }
                ans += dp[i][mask];
            }
        }
    }

    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 3 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 6968 KB Output is correct
2 Correct 129 ms 6324 KB Output is correct
3 Runtime error 36 ms 31328 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 3 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 151 ms 6968 KB Output is correct
12 Correct 129 ms 6324 KB Output is correct
13 Runtime error 36 ms 31328 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 44 ms 3816 KB Output is correct
3 Correct 51 ms 3772 KB Output is correct
4 Correct 162 ms 18256 KB Output is correct
5 Correct 130 ms 19076 KB Output is correct
6 Correct 161 ms 18248 KB Output is correct
7 Correct 42 ms 3800 KB Output is correct
8 Correct 164 ms 18328 KB Output is correct
9 Correct 143 ms 19024 KB Output is correct
10 Correct 179 ms 19240 KB Output is correct
11 Correct 104 ms 10900 KB Output is correct
12 Correct 117 ms 15108 KB Output is correct
13 Correct 132 ms 11104 KB Output is correct
14 Correct 158 ms 18416 KB Output is correct
15 Correct 162 ms 18328 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2680 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct