Submission #1061400

# Submission time Handle Problem Language Result Execution time Memory
1061400 2024-08-16T08:40:52 Z warrenn Paths (BOI18_paths) C++14
100 / 100
332 ms 62556 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 

signed main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>adj[n+1];
    int a[n+1];
    for(int q=0;q<n;q++){
        cin>>a[q];
        a[q]--;
    }
    for(int q=1;q<=m;q++){
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int ans=0;
    int dp[n+1][(1<<k)];
    memset(dp,0,sizeof dp);

    for(int q=0;q<n;q++){
        dp[q][(1<<a[q])]=1;
    }
   
    for(int apa=1;apa<(1<<k);apa++){
        for(int q=0;q<n;q++){
            if(!(apa & (1<<a[q])))continue;
            for(auto v : adj[q]){
                dp[q][apa]+=dp[v][(apa-(1<<a[q]))];
               // cout<<dp[q][apa]<<endl;
            }
        }
    }
    for(int q=0;q<n;q++){
        for(int w=1;w<(1<<k);w++){
            ans+=dp[q][w];
        }
    }
    cout<<ans-n<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 10736 KB Output is correct
2 Correct 74 ms 9812 KB Output is correct
3 Correct 225 ms 43368 KB Output is correct
4 Correct 132 ms 13652 KB Output is correct
5 Correct 114 ms 13136 KB Output is correct
6 Correct 170 ms 31932 KB Output is correct
7 Correct 263 ms 43604 KB Output is correct
8 Correct 224 ms 43944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 98 ms 10736 KB Output is correct
12 Correct 74 ms 9812 KB Output is correct
13 Correct 225 ms 43368 KB Output is correct
14 Correct 132 ms 13652 KB Output is correct
15 Correct 114 ms 13136 KB Output is correct
16 Correct 170 ms 31932 KB Output is correct
17 Correct 263 ms 43604 KB Output is correct
18 Correct 224 ms 43944 KB Output is correct
19 Correct 91 ms 10920 KB Output is correct
20 Correct 74 ms 9816 KB Output is correct
21 Correct 220 ms 43348 KB Output is correct
22 Correct 115 ms 13652 KB Output is correct
23 Correct 130 ms 13288 KB Output is correct
24 Correct 167 ms 31936 KB Output is correct
25 Correct 280 ms 43396 KB Output is correct
26 Correct 231 ms 43940 KB Output is correct
27 Correct 75 ms 9812 KB Output is correct
28 Correct 103 ms 12884 KB Output is correct
29 Correct 294 ms 62292 KB Output is correct
30 Correct 200 ms 36548 KB Output is correct
31 Correct 215 ms 36548 KB Output is correct
32 Correct 332 ms 62556 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 35 ms 3416 KB Output is correct
3 Correct 25 ms 3156 KB Output is correct
4 Correct 63 ms 14428 KB Output is correct
5 Correct 56 ms 15036 KB Output is correct
6 Correct 101 ms 33352 KB Output is correct
7 Correct 26 ms 3420 KB Output is correct
8 Correct 78 ms 20820 KB Output is correct
9 Correct 62 ms 21192 KB Output is correct
10 Correct 72 ms 20936 KB Output is correct
11 Correct 62 ms 18128 KB Output is correct
12 Correct 71 ms 25924 KB Output is correct
13 Correct 63 ms 18404 KB Output is correct
14 Correct 102 ms 33364 KB Output is correct
15 Correct 101 ms 33364 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 432 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct