# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
941746 | 2024-03-09T11:40:58 Z | dshfjka | Paths (BOI18_paths) | C++14 | 333 ms | 117648 KB |
#include <bits/stdc++.h> #define LL long long const LL N=3e5; using namespace std; LL n,m,k; LL dp[N+5][35]; bool visited[N+5][35]; LL arr[N+5]; vector<LL>adj[N+5]; LL f(LL x, LL mask) { if(visited[x][mask])return dp[x][mask]; visited[x][mask]=1; LL &dyn = dp[x][mask]; dyn=1; for(LL a:adj[x]) { if(mask&(1<<arr[a]))continue; dyn+=f(a,mask+(1<<arr[a])); } return dyn; } int main() { scanf("%lld %lld %lld",&n,&m,&k); for(LL a=1;a<=n;a++) { scanf("%lld",&arr[a]); arr[a]--; } for(LL a=1;a<=m;a++) { LL x,y; scanf("%lld %lld",&x,&y); adj[x].push_back(y); adj[y].push_back(x); } LL res=0; for(LL a=1;a<=n;a++) { res+=f(a,1LL<<arr[a]); // printf("%lld : %lld\n",a,res); } printf("%lld\n",res-n); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10840 KB | Output is correct |
2 | Correct | 2 ms | 10844 KB | Output is correct |
3 | Correct | 2 ms | 10860 KB | Output is correct |
4 | Correct | 2 ms | 10844 KB | Output is correct |
5 | Correct | 2 ms | 10844 KB | Output is correct |
6 | Correct | 2 ms | 10884 KB | Output is correct |
7 | Correct | 2 ms | 10844 KB | Output is correct |
8 | Correct | 2 ms | 10844 KB | Output is correct |
9 | Correct | 4 ms | 10844 KB | Output is correct |
10 | Correct | 2 ms | 10880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 22924 KB | Output is correct |
2 | Correct | 73 ms | 20132 KB | Output is correct |
3 | Correct | 299 ms | 117072 KB | Output is correct |
4 | Correct | 88 ms | 31604 KB | Output is correct |
5 | Correct | 82 ms | 31572 KB | Output is correct |
6 | Correct | 172 ms | 87076 KB | Output is correct |
7 | Correct | 281 ms | 117272 KB | Output is correct |
8 | Correct | 260 ms | 117648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10840 KB | Output is correct |
2 | Correct | 2 ms | 10844 KB | Output is correct |
3 | Correct | 2 ms | 10860 KB | Output is correct |
4 | Correct | 2 ms | 10844 KB | Output is correct |
5 | Correct | 2 ms | 10844 KB | Output is correct |
6 | Correct | 2 ms | 10884 KB | Output is correct |
7 | Correct | 2 ms | 10844 KB | Output is correct |
8 | Correct | 2 ms | 10844 KB | Output is correct |
9 | Correct | 4 ms | 10844 KB | Output is correct |
10 | Correct | 2 ms | 10880 KB | Output is correct |
11 | Correct | 67 ms | 22924 KB | Output is correct |
12 | Correct | 73 ms | 20132 KB | Output is correct |
13 | Correct | 299 ms | 117072 KB | Output is correct |
14 | Correct | 88 ms | 31604 KB | Output is correct |
15 | Correct | 82 ms | 31572 KB | Output is correct |
16 | Correct | 172 ms | 87076 KB | Output is correct |
17 | Correct | 281 ms | 117272 KB | Output is correct |
18 | Correct | 260 ms | 117648 KB | Output is correct |
19 | Correct | 71 ms | 23124 KB | Output is correct |
20 | Correct | 56 ms | 20288 KB | Output is correct |
21 | Correct | 308 ms | 117072 KB | Output is correct |
22 | Correct | 84 ms | 31532 KB | Output is correct |
23 | Correct | 74 ms | 31420 KB | Output is correct |
24 | Correct | 196 ms | 86868 KB | Output is correct |
25 | Correct | 243 ms | 117072 KB | Output is correct |
26 | Correct | 229 ms | 117588 KB | Output is correct |
27 | Correct | 71 ms | 20052 KB | Output is correct |
28 | Correct | 113 ms | 24400 KB | Output is correct |
29 | Correct | 318 ms | 117068 KB | Output is correct |
30 | Correct | 229 ms | 69576 KB | Output is correct |
31 | Correct | 253 ms | 69952 KB | Output is correct |
32 | Correct | 333 ms | 117536 KB | Output is correct |
33 | Correct | 2 ms | 10844 KB | Output is correct |
34 | Correct | 2 ms | 10844 KB | Output is correct |
35 | Correct | 3 ms | 10844 KB | Output is correct |
36 | Correct | 3 ms | 10880 KB | Output is correct |
37 | Correct | 3 ms | 10844 KB | Output is correct |
38 | Correct | 2 ms | 10844 KB | Output is correct |
39 | Correct | 2 ms | 10844 KB | Output is correct |
40 | Correct | 2 ms | 10912 KB | Output is correct |
41 | Correct | 2 ms | 10844 KB | Output is correct |
42 | Correct | 3 ms | 10844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10880 KB | Output is correct |
2 | Correct | 36 ms | 13660 KB | Output is correct |
3 | Correct | 20 ms | 13656 KB | Output is correct |
4 | Correct | 61 ms | 45592 KB | Output is correct |
5 | Correct | 49 ms | 46020 KB | Output is correct |
6 | Correct | 80 ms | 45648 KB | Output is correct |
7 | Correct | 25 ms | 13660 KB | Output is correct |
8 | Correct | 93 ms | 45652 KB | Output is correct |
9 | Correct | 56 ms | 46156 KB | Output is correct |
10 | Correct | 67 ms | 45776 KB | Output is correct |
11 | Correct | 62 ms | 30716 KB | Output is correct |
12 | Correct | 57 ms | 38336 KB | Output is correct |
13 | Correct | 80 ms | 30936 KB | Output is correct |
14 | Correct | 77 ms | 45828 KB | Output is correct |
15 | Correct | 69 ms | 45904 KB | Output is correct |
16 | Correct | 2 ms | 10840 KB | Output is correct |
17 | Correct | 2 ms | 10840 KB | Output is correct |
18 | Correct | 2 ms | 10844 KB | Output is correct |
19 | Correct | 3 ms | 10844 KB | Output is correct |
20 | Correct | 2 ms | 10844 KB | Output is correct |
21 | Correct | 2 ms | 10844 KB | Output is correct |
22 | Correct | 2 ms | 10844 KB | Output is correct |
23 | Correct | 2 ms | 10844 KB | Output is correct |
24 | Correct | 2 ms | 10844 KB | Output is correct |
25 | Correct | 2 ms | 10844 KB | Output is correct |