# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
307842 |
2020-09-29T11:48:03 Z |
2fat2code |
Paths (BOI18_paths) |
C++17 |
|
752 ms |
173048 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
const int nmax = 300005;
const int mask = (1 << 5);
int n,m,k,dp[nmax][mask],tz[nmax][mask],color[nmax],ans;
vector<int>nod[nmax];
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
srand(chrono::steady_clock::now().time_since_epoch().count());
// freopen("input.in","r",stdin);
cin >> n >> m >> k;
for(int i=1;i<=n;i++){
cin >> color[i];
dp[i][1 << (color[i] - 1)] = 1;
}
for(int i=1;i<=m;i++){
int x,y;
cin >> x >> y;
nod[x].push_back(y);
nod[y].push_back(x);
}
for(int i=2;i<=k;i++){
for(int j=1;j<=n;j++){
for(int t=1;t<(1 << k);t++){
tz[j][t] = dp[j][t];
dp[j][t] = 0;
}
}
for(int j=1;j<=n;j++){
for(auto it : nod[j]){
for(int t=1;t<(1<<k);t++){
if((t&(1<<(color[j] - 1))) == 0){
dp[j][t^(1<<(color[j]-1))] += tz[it][t];
}
}
}
}
for(int j=1;j<=n;j++){
for(int t=1;t<(1<<k);t++){
ans += dp[j][t];
}
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
6 ms |
7424 KB |
Output is correct |
4 |
Correct |
6 ms |
7456 KB |
Output is correct |
5 |
Correct |
6 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7424 KB |
Output is correct |
7 |
Correct |
6 ms |
7424 KB |
Output is correct |
8 |
Correct |
6 ms |
7424 KB |
Output is correct |
9 |
Correct |
5 ms |
7424 KB |
Output is correct |
10 |
Correct |
5 ms |
7424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
18936 KB |
Output is correct |
2 |
Correct |
72 ms |
16760 KB |
Output is correct |
3 |
Correct |
503 ms |
172536 KB |
Output is correct |
4 |
Correct |
159 ms |
32636 KB |
Output is correct |
5 |
Correct |
125 ms |
25196 KB |
Output is correct |
6 |
Correct |
359 ms |
119908 KB |
Output is correct |
7 |
Correct |
501 ms |
172536 KB |
Output is correct |
8 |
Correct |
510 ms |
173048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
6 ms |
7424 KB |
Output is correct |
4 |
Correct |
6 ms |
7456 KB |
Output is correct |
5 |
Correct |
6 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7424 KB |
Output is correct |
7 |
Correct |
6 ms |
7424 KB |
Output is correct |
8 |
Correct |
6 ms |
7424 KB |
Output is correct |
9 |
Correct |
5 ms |
7424 KB |
Output is correct |
10 |
Correct |
5 ms |
7424 KB |
Output is correct |
11 |
Correct |
97 ms |
18936 KB |
Output is correct |
12 |
Correct |
72 ms |
16760 KB |
Output is correct |
13 |
Correct |
503 ms |
172536 KB |
Output is correct |
14 |
Correct |
159 ms |
32636 KB |
Output is correct |
15 |
Correct |
125 ms |
25196 KB |
Output is correct |
16 |
Correct |
359 ms |
119908 KB |
Output is correct |
17 |
Correct |
501 ms |
172536 KB |
Output is correct |
18 |
Correct |
510 ms |
173048 KB |
Output is correct |
19 |
Correct |
100 ms |
19064 KB |
Output is correct |
20 |
Correct |
75 ms |
16760 KB |
Output is correct |
21 |
Correct |
504 ms |
172536 KB |
Output is correct |
22 |
Correct |
162 ms |
32632 KB |
Output is correct |
23 |
Correct |
133 ms |
25080 KB |
Output is correct |
24 |
Correct |
371 ms |
119908 KB |
Output is correct |
25 |
Correct |
504 ms |
172408 KB |
Output is correct |
26 |
Correct |
516 ms |
173048 KB |
Output is correct |
27 |
Correct |
94 ms |
16760 KB |
Output is correct |
28 |
Correct |
141 ms |
21880 KB |
Output is correct |
29 |
Correct |
752 ms |
172576 KB |
Output is correct |
30 |
Correct |
516 ms |
94292 KB |
Output is correct |
31 |
Correct |
537 ms |
94576 KB |
Output is correct |
32 |
Correct |
749 ms |
172664 KB |
Output is correct |
33 |
Correct |
5 ms |
7424 KB |
Output is correct |
34 |
Correct |
5 ms |
7424 KB |
Output is correct |
35 |
Correct |
6 ms |
7424 KB |
Output is correct |
36 |
Correct |
6 ms |
7424 KB |
Output is correct |
37 |
Correct |
6 ms |
7424 KB |
Output is correct |
38 |
Correct |
6 ms |
7424 KB |
Output is correct |
39 |
Correct |
5 ms |
7424 KB |
Output is correct |
40 |
Correct |
6 ms |
7424 KB |
Output is correct |
41 |
Correct |
6 ms |
7424 KB |
Output is correct |
42 |
Correct |
6 ms |
7424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
53 ms |
10464 KB |
Output is correct |
3 |
Correct |
28 ms |
10488 KB |
Output is correct |
4 |
Correct |
164 ms |
63096 KB |
Output is correct |
5 |
Correct |
114 ms |
63596 KB |
Output is correct |
6 |
Correct |
313 ms |
63224 KB |
Output is correct |
7 |
Correct |
35 ms |
10496 KB |
Output is correct |
8 |
Correct |
234 ms |
63352 KB |
Output is correct |
9 |
Correct |
171 ms |
63592 KB |
Output is correct |
10 |
Correct |
198 ms |
63340 KB |
Output is correct |
11 |
Correct |
184 ms |
36592 KB |
Output is correct |
12 |
Correct |
203 ms |
50024 KB |
Output is correct |
13 |
Correct |
182 ms |
36712 KB |
Output is correct |
14 |
Correct |
301 ms |
63224 KB |
Output is correct |
15 |
Correct |
315 ms |
63352 KB |
Output is correct |
16 |
Correct |
5 ms |
7424 KB |
Output is correct |
17 |
Correct |
6 ms |
7424 KB |
Output is correct |
18 |
Correct |
6 ms |
7424 KB |
Output is correct |
19 |
Correct |
5 ms |
7424 KB |
Output is correct |
20 |
Correct |
6 ms |
7424 KB |
Output is correct |
21 |
Correct |
6 ms |
7552 KB |
Output is correct |
22 |
Correct |
6 ms |
7424 KB |
Output is correct |
23 |
Correct |
7 ms |
7424 KB |
Output is correct |
24 |
Correct |
6 ms |
7424 KB |
Output is correct |
25 |
Correct |
6 ms |
7424 KB |
Output is correct |