Submission #984457

# Submission time Handle Problem Language Result Execution time Memory
984457 2024-05-16T17:01:59 Z Ahmed57 Paths (BOI18_paths) C++17
100 / 100
455 ms 100540 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
int n,m,k;
vector<int> adj[300001];
int dp[300001][(1<<5)],arr[300001];
int solve(int i,int mask){
    if(dp[i][mask]!=-1)return dp[i][mask];
    int c1 = 1;
    for(auto j:adj[i]){
        if(mask&(1<<arr[j]))continue;
        c1+=solve(j,mask^(1<<arr[j]));
    }return dp[i][mask] = c1;
}
signed main(){
    cin>>n>>m>>k;
    for(int i = 1;i<=n;i++){
        cin>>arr[i];
        arr[i]--;
    }
    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 all = 0;
    memset(dp,-1,sizeof dp);
    for(int i = 1;i<=n;i++)all+=solve(i,(1<<arr[i]));
    cout<<all-n<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 82520 KB Output is correct
2 Correct 12 ms 82524 KB Output is correct
3 Correct 12 ms 82520 KB Output is correct
4 Correct 11 ms 82524 KB Output is correct
5 Correct 14 ms 82524 KB Output is correct
6 Correct 12 ms 82524 KB Output is correct
7 Correct 12 ms 82524 KB Output is correct
8 Correct 12 ms 82524 KB Output is correct
9 Correct 12 ms 82604 KB Output is correct
10 Correct 12 ms 82524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 92752 KB Output is correct
2 Correct 106 ms 91984 KB Output is correct
3 Correct 369 ms 99956 KB Output is correct
4 Correct 156 ms 96340 KB Output is correct
5 Correct 145 ms 96336 KB Output is correct
6 Correct 273 ms 98108 KB Output is correct
7 Correct 317 ms 99920 KB Output is correct
8 Correct 338 ms 100540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 82520 KB Output is correct
2 Correct 12 ms 82524 KB Output is correct
3 Correct 12 ms 82520 KB Output is correct
4 Correct 11 ms 82524 KB Output is correct
5 Correct 14 ms 82524 KB Output is correct
6 Correct 12 ms 82524 KB Output is correct
7 Correct 12 ms 82524 KB Output is correct
8 Correct 12 ms 82524 KB Output is correct
9 Correct 12 ms 82604 KB Output is correct
10 Correct 12 ms 82524 KB Output is correct
11 Correct 129 ms 92752 KB Output is correct
12 Correct 106 ms 91984 KB Output is correct
13 Correct 369 ms 99956 KB Output is correct
14 Correct 156 ms 96340 KB Output is correct
15 Correct 145 ms 96336 KB Output is correct
16 Correct 273 ms 98108 KB Output is correct
17 Correct 317 ms 99920 KB Output is correct
18 Correct 338 ms 100540 KB Output is correct
19 Correct 127 ms 92556 KB Output is correct
20 Correct 106 ms 91988 KB Output is correct
21 Correct 371 ms 99960 KB Output is correct
22 Correct 155 ms 96332 KB Output is correct
23 Correct 153 ms 96396 KB Output is correct
24 Correct 264 ms 97724 KB Output is correct
25 Correct 352 ms 99920 KB Output is correct
26 Correct 321 ms 100508 KB Output is correct
27 Correct 121 ms 91988 KB Output is correct
28 Correct 151 ms 94124 KB Output is correct
29 Correct 392 ms 99920 KB Output is correct
30 Correct 305 ms 97716 KB Output is correct
31 Correct 332 ms 97756 KB Output is correct
32 Correct 455 ms 99924 KB Output is correct
33 Correct 14 ms 82524 KB Output is correct
34 Correct 12 ms 82524 KB Output is correct
35 Correct 11 ms 82524 KB Output is correct
36 Correct 11 ms 82624 KB Output is correct
37 Correct 11 ms 82524 KB Output is correct
38 Correct 13 ms 82660 KB Output is correct
39 Correct 12 ms 82652 KB Output is correct
40 Correct 15 ms 82524 KB Output is correct
41 Correct 12 ms 82524 KB Output is correct
42 Correct 12 ms 82524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 82524 KB Output is correct
2 Correct 60 ms 85572 KB Output is correct
3 Correct 43 ms 85584 KB Output is correct
4 Correct 92 ms 89680 KB Output is correct
5 Correct 78 ms 90056 KB Output is correct
6 Correct 120 ms 89748 KB Output is correct
7 Correct 48 ms 85860 KB Output is correct
8 Correct 98 ms 89816 KB Output is correct
9 Correct 83 ms 90056 KB Output is correct
10 Correct 93 ms 89968 KB Output is correct
11 Correct 88 ms 88520 KB Output is correct
12 Correct 96 ms 89412 KB Output is correct
13 Correct 86 ms 88868 KB Output is correct
14 Correct 113 ms 89768 KB Output is correct
15 Correct 119 ms 89908 KB Output is correct
16 Correct 11 ms 82524 KB Output is correct
17 Correct 12 ms 82708 KB Output is correct
18 Correct 12 ms 82744 KB Output is correct
19 Correct 13 ms 82524 KB Output is correct
20 Correct 12 ms 82524 KB Output is correct
21 Correct 12 ms 82524 KB Output is correct
22 Correct 12 ms 82524 KB Output is correct
23 Correct 12 ms 82524 KB Output is correct
24 Correct 12 ms 82660 KB Output is correct
25 Correct 11 ms 82708 KB Output is correct