답안 #703045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703045 2023-02-25T18:41:31 Z Ronin13 Paths (BOI18_paths) C++14
100 / 100
357 ms 97132 KB
#include <bits/stdc++.h>
#define ll long  long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back

using namespace std;
const int nmax = 2000001;
ll dp[nmax][32];
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    int k; cin >> k;

    int col[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> col[i];
        col[i]--;
        dp[i][(1 << col[i])] = 1;
    }
    vector <vector <int> >g(n + 1);
    for(int i = 1; i <= m; i++){
        int u, v; cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(int mask = 1; mask < (1 << k); mask++){
        for(int i = 1; i <= n; i++){
            if(mask & (1 << col[i])){
                for(int to : g[i]){
                    dp[i][mask] += dp[to][mask ^ (1 << col[i])];
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i < 32; i++){
        for(int v = 1; v <= n; v++){
            ans += dp[v][i];
        }
    }
    cout << ans - n;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 320 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 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 8100 KB Output is correct
2 Correct 46 ms 6300 KB Output is correct
3 Correct 279 ms 96468 KB Output is correct
4 Correct 124 ms 16332 KB Output is correct
5 Correct 84 ms 16336 KB Output is correct
6 Correct 199 ms 67024 KB Output is correct
7 Correct 308 ms 96440 KB Output is correct
8 Correct 316 ms 97132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 320 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 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 71 ms 8100 KB Output is correct
12 Correct 46 ms 6300 KB Output is correct
13 Correct 279 ms 96468 KB Output is correct
14 Correct 124 ms 16332 KB Output is correct
15 Correct 84 ms 16336 KB Output is correct
16 Correct 199 ms 67024 KB Output is correct
17 Correct 308 ms 96440 KB Output is correct
18 Correct 316 ms 97132 KB Output is correct
19 Correct 57 ms 8136 KB Output is correct
20 Correct 45 ms 6368 KB Output is correct
21 Correct 283 ms 96460 KB Output is correct
22 Correct 110 ms 16420 KB Output is correct
23 Correct 89 ms 16340 KB Output is correct
24 Correct 199 ms 67052 KB Output is correct
25 Correct 298 ms 96452 KB Output is correct
26 Correct 283 ms 97104 KB Output is correct
27 Correct 44 ms 6296 KB Output is correct
28 Correct 72 ms 9720 KB Output is correct
29 Correct 355 ms 96472 KB Output is correct
30 Correct 269 ms 51764 KB Output is correct
31 Correct 219 ms 51868 KB Output is correct
32 Correct 357 ms 96500 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 328 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 328 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 0 ms 328 KB Output is correct
41 Correct 1 ms 328 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 17 ms 2260 KB Output is correct
3 Correct 15 ms 2260 KB Output is correct
4 Correct 112 ms 32236 KB Output is correct
5 Correct 63 ms 32944 KB Output is correct
6 Correct 126 ms 32132 KB Output is correct
7 Correct 15 ms 2260 KB Output is correct
8 Correct 101 ms 32128 KB Output is correct
9 Correct 100 ms 32876 KB Output is correct
10 Correct 86 ms 32972 KB Output is correct
11 Correct 71 ms 17060 KB Output is correct
12 Correct 89 ms 25204 KB Output is correct
13 Correct 78 ms 17268 KB Output is correct
14 Correct 138 ms 32232 KB Output is correct
15 Correct 128 ms 32332 KB Output is correct
16 Correct 1 ms 212 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 332 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct