# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
213442 | 2020-03-25T20:22:34 Z | MKopchev | Paths (BOI18_paths) | C++14 | 420 ms | 54392 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=3e5+42; long long dp[32][nmax]; int colour[nmax]; vector<int> adj[nmax]; int n,m,k; long long rec(int remain,int pos) { if(remain==0)return 1; if(dp[remain][pos])return dp[remain][pos]; long long ret=1;//alone for(auto nxt:adj[pos]) if((remain&(1<<colour[nxt])))ret=ret+rec(remain-(1<<colour[nxt]),nxt); dp[remain][pos]=ret; return ret; } int main() { scanf("%i%i%i",&n,&m,&k); for(int i=1;i<=n;i++) { scanf("%i",&colour[i]); colour[i]--; } int u,v; for(int i=1;i<=m;i++) { scanf("%i%i",&u,&v); adj[u].push_back(v); adj[v].push_back(u); } long long ret=0; for(int i=1;i<=n;i++) ret=ret+rec((1<<k)-1-(1<<colour[i]),i)-1; printf("%lld\n",ret); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 7552 KB | Output is correct |
2 | Correct | 8 ms | 7552 KB | Output is correct |
3 | Correct | 8 ms | 7424 KB | Output is correct |
4 | Correct | 10 ms | 7424 KB | Output is correct |
5 | Correct | 8 ms | 7424 KB | Output is correct |
6 | Correct | 8 ms | 7552 KB | Output is correct |
7 | Correct | 8 ms | 7424 KB | Output is correct |
8 | Correct | 8 ms | 7552 KB | Output is correct |
9 | Correct | 9 ms | 7424 KB | Output is correct |
10 | Correct | 8 ms | 7424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 108 ms | 14072 KB | Output is correct |
2 | Correct | 92 ms | 13176 KB | Output is correct |
3 | Correct | 341 ms | 35556 KB | Output is correct |
4 | Correct | 136 ms | 15736 KB | Output is correct |
5 | Correct | 121 ms | 15356 KB | Output is correct |
6 | Correct | 244 ms | 28908 KB | Output is correct |
7 | Correct | 342 ms | 35576 KB | Output is correct |
8 | Correct | 344 ms | 36344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 7552 KB | Output is correct |
2 | Correct | 8 ms | 7552 KB | Output is correct |
3 | Correct | 8 ms | 7424 KB | Output is correct |
4 | Correct | 10 ms | 7424 KB | Output is correct |
5 | Correct | 8 ms | 7424 KB | Output is correct |
6 | Correct | 8 ms | 7552 KB | Output is correct |
7 | Correct | 8 ms | 7424 KB | Output is correct |
8 | Correct | 8 ms | 7552 KB | Output is correct |
9 | Correct | 9 ms | 7424 KB | Output is correct |
10 | Correct | 8 ms | 7424 KB | Output is correct |
11 | Correct | 108 ms | 14072 KB | Output is correct |
12 | Correct | 92 ms | 13176 KB | Output is correct |
13 | Correct | 341 ms | 35556 KB | Output is correct |
14 | Correct | 136 ms | 15736 KB | Output is correct |
15 | Correct | 121 ms | 15356 KB | Output is correct |
16 | Correct | 244 ms | 28908 KB | Output is correct |
17 | Correct | 342 ms | 35576 KB | Output is correct |
18 | Correct | 344 ms | 36344 KB | Output is correct |
19 | Correct | 107 ms | 14072 KB | Output is correct |
20 | Correct | 93 ms | 13176 KB | Output is correct |
21 | Correct | 341 ms | 35636 KB | Output is correct |
22 | Correct | 130 ms | 15736 KB | Output is correct |
23 | Correct | 122 ms | 15224 KB | Output is correct |
24 | Correct | 246 ms | 28776 KB | Output is correct |
25 | Correct | 344 ms | 35448 KB | Output is correct |
26 | Correct | 330 ms | 36088 KB | Output is correct |
27 | Correct | 106 ms | 13308 KB | Output is correct |
28 | Correct | 132 ms | 15612 KB | Output is correct |
29 | Correct | 407 ms | 54268 KB | Output is correct |
30 | Correct | 291 ms | 34408 KB | Output is correct |
31 | Correct | 312 ms | 31984 KB | Output is correct |
32 | Correct | 420 ms | 54392 KB | Output is correct |
33 | Correct | 9 ms | 7552 KB | Output is correct |
34 | Correct | 8 ms | 7552 KB | Output is correct |
35 | Correct | 9 ms | 7424 KB | Output is correct |
36 | Correct | 8 ms | 7424 KB | Output is correct |
37 | Correct | 9 ms | 7424 KB | Output is correct |
38 | Correct | 9 ms | 7424 KB | Output is correct |
39 | Correct | 9 ms | 7424 KB | Output is correct |
40 | Correct | 8 ms | 7552 KB | Output is correct |
41 | Correct | 8 ms | 7424 KB | Output is correct |
42 | Correct | 8 ms | 7424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 7424 KB | Output is correct |
2 | Correct | 53 ms | 9464 KB | Output is correct |
3 | Correct | 36 ms | 9216 KB | Output is correct |
4 | Correct | 87 ms | 16632 KB | Output is correct |
5 | Correct | 65 ms | 16624 KB | Output is correct |
6 | Correct | 135 ms | 35576 KB | Output is correct |
7 | Correct | 42 ms | 9340 KB | Output is correct |
8 | Correct | 108 ms | 22904 KB | Output is correct |
9 | Correct | 72 ms | 20592 KB | Output is correct |
10 | Correct | 100 ms | 18976 KB | Output is correct |
11 | Correct | 96 ms | 22516 KB | Output is correct |
12 | Correct | 70 ms | 18288 KB | Output is correct |
13 | Correct | 84 ms | 19056 KB | Output is correct |
14 | Correct | 133 ms | 35576 KB | Output is correct |
15 | Correct | 126 ms | 35704 KB | Output is correct |
16 | Correct | 9 ms | 7552 KB | Output is correct |
17 | Correct | 8 ms | 7552 KB | Output is correct |
18 | Correct | 8 ms | 7424 KB | Output is correct |
19 | Correct | 9 ms | 7424 KB | Output is correct |
20 | Correct | 8 ms | 7424 KB | Output is correct |
21 | Correct | 8 ms | 7552 KB | Output is correct |
22 | Correct | 8 ms | 7424 KB | Output is correct |
23 | Correct | 9 ms | 7552 KB | Output is correct |
24 | Correct | 9 ms | 7400 KB | Output is correct |
25 | Correct | 8 ms | 7424 KB | Output is correct |