# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
363463 |
2021-02-06T07:12:35 Z |
knightron0 |
Paths (BOI18_paths) |
C++14 |
|
717 ms |
74348 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
#define clr(a, x) memset(a, x, sizeof(a))
#define dbg(x) cout<<"("<<#x<<"): "<<x<<endl;
#define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define all(v) v.begin(), v.end()
#define lcm(a, b) (a * b)/__gcd(a, b)
#define int long long int
#define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl;
#define endl '\n'
#define float long double
const int MOD = 1e9 + 7;
const int INF = 2e15;
const int MAXN = 5e5 + 5;
vector<int> adj[MAXN];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int n, m, k;
cin>>n>>m>>k;
int col[n+4];
for(int i= 1;i<=n;i++){
cin>>col[i];
col[i]--;
}
for(int i= 0;i<m;i++){
int t1, t2;
cin>>t1>>t2;
adj[t1].pb(t2);
adj[t2].pb(t1);
}
int dp[n+3][(1<<k)+3];
clr(dp, 0);
for(int i= 1;i<=n;i++){
dp[i][(1<<col[i])] = 1;
}
int ans= 0;
for(int mask = 0;mask<(1<<k);mask++){
for(int i= 1;i<=n;i++){
if((1<<col[i])&mask){
for(int v: adj[i]){
int newmask = (1<<col[v]) | mask;
if((1<<col[v]) & mask) continue;
dp[v][newmask] += dp[i][mask];
if(__builtin_popcount(newmask)>1){
ans += dp[i][mask];
}
}
}
}
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
12012 KB |
Output is correct |
2 |
Correct |
9 ms |
12140 KB |
Output is correct |
3 |
Correct |
8 ms |
12012 KB |
Output is correct |
4 |
Correct |
9 ms |
12012 KB |
Output is correct |
5 |
Correct |
10 ms |
12012 KB |
Output is correct |
6 |
Correct |
10 ms |
12140 KB |
Output is correct |
7 |
Correct |
8 ms |
12140 KB |
Output is correct |
8 |
Correct |
9 ms |
12140 KB |
Output is correct |
9 |
Correct |
8 ms |
12012 KB |
Output is correct |
10 |
Correct |
8 ms |
12012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
19820 KB |
Output is correct |
2 |
Correct |
93 ms |
19308 KB |
Output is correct |
3 |
Correct |
463 ms |
54584 KB |
Output is correct |
4 |
Correct |
150 ms |
25452 KB |
Output is correct |
5 |
Correct |
153 ms |
25196 KB |
Output is correct |
6 |
Correct |
321 ms |
43868 KB |
Output is correct |
7 |
Correct |
471 ms |
55276 KB |
Output is correct |
8 |
Correct |
477 ms |
55788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
12012 KB |
Output is correct |
2 |
Correct |
9 ms |
12140 KB |
Output is correct |
3 |
Correct |
8 ms |
12012 KB |
Output is correct |
4 |
Correct |
9 ms |
12012 KB |
Output is correct |
5 |
Correct |
10 ms |
12012 KB |
Output is correct |
6 |
Correct |
10 ms |
12140 KB |
Output is correct |
7 |
Correct |
8 ms |
12140 KB |
Output is correct |
8 |
Correct |
9 ms |
12140 KB |
Output is correct |
9 |
Correct |
8 ms |
12012 KB |
Output is correct |
10 |
Correct |
8 ms |
12012 KB |
Output is correct |
11 |
Correct |
104 ms |
19820 KB |
Output is correct |
12 |
Correct |
93 ms |
19308 KB |
Output is correct |
13 |
Correct |
463 ms |
54584 KB |
Output is correct |
14 |
Correct |
150 ms |
25452 KB |
Output is correct |
15 |
Correct |
153 ms |
25196 KB |
Output is correct |
16 |
Correct |
321 ms |
43868 KB |
Output is correct |
17 |
Correct |
471 ms |
55276 KB |
Output is correct |
18 |
Correct |
477 ms |
55788 KB |
Output is correct |
19 |
Correct |
99 ms |
22636 KB |
Output is correct |
20 |
Correct |
85 ms |
21612 KB |
Output is correct |
21 |
Correct |
442 ms |
55404 KB |
Output is correct |
22 |
Correct |
148 ms |
25452 KB |
Output is correct |
23 |
Correct |
141 ms |
25108 KB |
Output is correct |
24 |
Correct |
309 ms |
43868 KB |
Output is correct |
25 |
Correct |
451 ms |
55404 KB |
Output is correct |
26 |
Correct |
481 ms |
56044 KB |
Output is correct |
27 |
Correct |
118 ms |
21612 KB |
Output is correct |
28 |
Correct |
142 ms |
24812 KB |
Output is correct |
29 |
Correct |
692 ms |
74292 KB |
Output is correct |
30 |
Correct |
427 ms |
48348 KB |
Output is correct |
31 |
Correct |
478 ms |
48352 KB |
Output is correct |
32 |
Correct |
717 ms |
74348 KB |
Output is correct |
33 |
Correct |
9 ms |
12140 KB |
Output is correct |
34 |
Correct |
8 ms |
12140 KB |
Output is correct |
35 |
Correct |
8 ms |
12140 KB |
Output is correct |
36 |
Correct |
9 ms |
12140 KB |
Output is correct |
37 |
Correct |
9 ms |
12140 KB |
Output is correct |
38 |
Correct |
8 ms |
12140 KB |
Output is correct |
39 |
Correct |
9 ms |
12140 KB |
Output is correct |
40 |
Correct |
9 ms |
12140 KB |
Output is correct |
41 |
Correct |
9 ms |
12012 KB |
Output is correct |
42 |
Correct |
8 ms |
12012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
12012 KB |
Output is correct |
2 |
Correct |
50 ms |
14316 KB |
Output is correct |
3 |
Correct |
33 ms |
14316 KB |
Output is correct |
4 |
Correct |
123 ms |
24940 KB |
Output is correct |
5 |
Correct |
83 ms |
25440 KB |
Output is correct |
6 |
Correct |
306 ms |
43756 KB |
Output is correct |
7 |
Correct |
38 ms |
14316 KB |
Output is correct |
8 |
Correct |
181 ms |
31340 KB |
Output is correct |
9 |
Correct |
128 ms |
31672 KB |
Output is correct |
10 |
Correct |
163 ms |
31328 KB |
Output is correct |
11 |
Correct |
174 ms |
28864 KB |
Output is correct |
12 |
Correct |
185 ms |
36316 KB |
Output is correct |
13 |
Correct |
170 ms |
28892 KB |
Output is correct |
14 |
Correct |
303 ms |
43756 KB |
Output is correct |
15 |
Correct |
282 ms |
43884 KB |
Output is correct |
16 |
Correct |
8 ms |
12012 KB |
Output is correct |
17 |
Correct |
9 ms |
12140 KB |
Output is correct |
18 |
Correct |
10 ms |
12012 KB |
Output is correct |
19 |
Correct |
9 ms |
12012 KB |
Output is correct |
20 |
Correct |
8 ms |
12012 KB |
Output is correct |
21 |
Correct |
10 ms |
12140 KB |
Output is correct |
22 |
Correct |
9 ms |
12140 KB |
Output is correct |
23 |
Correct |
9 ms |
12140 KB |
Output is correct |
24 |
Correct |
9 ms |
12012 KB |
Output is correct |
25 |
Correct |
9 ms |
12012 KB |
Output is correct |