# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
518388 |
2022-01-23T15:56:54 Z |
Ierus |
Paths (BOI18_paths) |
C++17 |
|
556 ms |
317460 KB |
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
typedef long long ll;
const int E = 1e6+777;
const long long inf = 1e18+777;
const int N = 3e5+324;
const int MOD = 1e9+7;
long long res;
int n, m, k, c[N];
vector<int> g[N];
long long cnt[6][N][(1<<5)];
void Count(int v, int x){
for(auto to : g[v]){
if(c[to] == c[v]) continue;
for(int mask = 0; mask < (1 << k); ++mask){
if(((mask >> c[v]) & 1)) continue;
cnt[x][v][mask|(1<<c[v])] += cnt[x-1][to][mask];
};
};
}
int main(){
ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
cin >> n >> m >> k;
for(int i = 1; i <= n; ++i){
cin >> c[i]; --c[i];
cnt[1][i][(1<<c[i])] = 1;
}
for(int i = 1; i <= m; ++i){
int x, y;
cin >> x >> y;
g[x].pb(y);
g[y].pb(x);
}
for(int x = 2; x <= k; ++x){
for(int i = 1; i <= n; ++i){
Count(i, x);
}
}
long long sum = 0;
for(int kk = 2; kk <= k; ++kk){
for(int i = 1; i <= n; ++i){
for(int j = 0; j < (1 << k); ++j){
sum += cnt[kk][i][j];
}
}
}
cout << sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7372 KB |
Output is correct |
2 |
Correct |
4 ms |
7500 KB |
Output is correct |
3 |
Correct |
6 ms |
7372 KB |
Output is correct |
4 |
Correct |
4 ms |
7372 KB |
Output is correct |
5 |
Correct |
4 ms |
7372 KB |
Output is correct |
6 |
Correct |
4 ms |
7500 KB |
Output is correct |
7 |
Correct |
4 ms |
7372 KB |
Output is correct |
8 |
Correct |
4 ms |
7500 KB |
Output is correct |
9 |
Correct |
4 ms |
7392 KB |
Output is correct |
10 |
Correct |
4 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
14772 KB |
Output is correct |
2 |
Correct |
55 ms |
11484 KB |
Output is correct |
3 |
Correct |
376 ms |
242380 KB |
Output is correct |
4 |
Correct |
91 ms |
26960 KB |
Output is correct |
5 |
Correct |
79 ms |
19384 KB |
Output is correct |
6 |
Correct |
255 ms |
165528 KB |
Output is correct |
7 |
Correct |
342 ms |
242360 KB |
Output is correct |
8 |
Correct |
346 ms |
242944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7372 KB |
Output is correct |
2 |
Correct |
4 ms |
7500 KB |
Output is correct |
3 |
Correct |
6 ms |
7372 KB |
Output is correct |
4 |
Correct |
4 ms |
7372 KB |
Output is correct |
5 |
Correct |
4 ms |
7372 KB |
Output is correct |
6 |
Correct |
4 ms |
7500 KB |
Output is correct |
7 |
Correct |
4 ms |
7372 KB |
Output is correct |
8 |
Correct |
4 ms |
7500 KB |
Output is correct |
9 |
Correct |
4 ms |
7392 KB |
Output is correct |
10 |
Correct |
4 ms |
7372 KB |
Output is correct |
11 |
Correct |
89 ms |
14772 KB |
Output is correct |
12 |
Correct |
55 ms |
11484 KB |
Output is correct |
13 |
Correct |
376 ms |
242380 KB |
Output is correct |
14 |
Correct |
91 ms |
26960 KB |
Output is correct |
15 |
Correct |
79 ms |
19384 KB |
Output is correct |
16 |
Correct |
255 ms |
165528 KB |
Output is correct |
17 |
Correct |
342 ms |
242360 KB |
Output is correct |
18 |
Correct |
346 ms |
242944 KB |
Output is correct |
19 |
Correct |
65 ms |
14820 KB |
Output is correct |
20 |
Correct |
54 ms |
11576 KB |
Output is correct |
21 |
Correct |
346 ms |
242320 KB |
Output is correct |
22 |
Correct |
135 ms |
26884 KB |
Output is correct |
23 |
Correct |
85 ms |
19396 KB |
Output is correct |
24 |
Correct |
238 ms |
165532 KB |
Output is correct |
25 |
Correct |
327 ms |
242252 KB |
Output is correct |
26 |
Correct |
372 ms |
242996 KB |
Output is correct |
27 |
Correct |
88 ms |
11720 KB |
Output is correct |
28 |
Correct |
100 ms |
19780 KB |
Output is correct |
29 |
Correct |
501 ms |
317408 KB |
Output is correct |
30 |
Correct |
330 ms |
164024 KB |
Output is correct |
31 |
Correct |
357 ms |
164152 KB |
Output is correct |
32 |
Correct |
556 ms |
317460 KB |
Output is correct |
33 |
Correct |
4 ms |
7372 KB |
Output is correct |
34 |
Correct |
6 ms |
7500 KB |
Output is correct |
35 |
Correct |
4 ms |
7372 KB |
Output is correct |
36 |
Correct |
4 ms |
7372 KB |
Output is correct |
37 |
Correct |
4 ms |
7336 KB |
Output is correct |
38 |
Correct |
5 ms |
7500 KB |
Output is correct |
39 |
Correct |
6 ms |
7472 KB |
Output is correct |
40 |
Correct |
4 ms |
7500 KB |
Output is correct |
41 |
Correct |
4 ms |
7416 KB |
Output is correct |
42 |
Correct |
4 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
34 ms |
9084 KB |
Output is correct |
3 |
Correct |
24 ms |
8848 KB |
Output is correct |
4 |
Correct |
114 ms |
85676 KB |
Output is correct |
5 |
Correct |
82 ms |
86376 KB |
Output is correct |
6 |
Correct |
235 ms |
135812 KB |
Output is correct |
7 |
Correct |
27 ms |
8932 KB |
Output is correct |
8 |
Correct |
152 ms |
110772 KB |
Output is correct |
9 |
Correct |
118 ms |
111456 KB |
Output is correct |
10 |
Correct |
160 ms |
111292 KB |
Output is correct |
11 |
Correct |
131 ms |
72060 KB |
Output is correct |
12 |
Correct |
144 ms |
104376 KB |
Output is correct |
13 |
Correct |
141 ms |
71996 KB |
Output is correct |
14 |
Correct |
243 ms |
135748 KB |
Output is correct |
15 |
Correct |
228 ms |
136012 KB |
Output is correct |
16 |
Correct |
4 ms |
7372 KB |
Output is correct |
17 |
Correct |
4 ms |
7500 KB |
Output is correct |
18 |
Correct |
4 ms |
7372 KB |
Output is correct |
19 |
Correct |
4 ms |
7372 KB |
Output is correct |
20 |
Correct |
5 ms |
7372 KB |
Output is correct |
21 |
Correct |
4 ms |
7500 KB |
Output is correct |
22 |
Correct |
4 ms |
7372 KB |
Output is correct |
23 |
Correct |
5 ms |
7500 KB |
Output is correct |
24 |
Correct |
4 ms |
7416 KB |
Output is correct |
25 |
Correct |
4 ms |
7372 KB |
Output is correct |