# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
518386 |
2022-01-23T15:56:13 Z |
Ierus |
Paths (BOI18_paths) |
C++17 |
|
507 ms |
317520 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[5][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 |
7512 KB |
Output is correct |
3 |
Correct |
4 ms |
7372 KB |
Output is correct |
4 |
Correct |
5 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 |
5 ms |
7464 KB |
Output is correct |
9 |
Correct |
4 ms |
7372 KB |
Output is correct |
10 |
Correct |
4 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
14752 KB |
Output is correct |
2 |
Correct |
51 ms |
11460 KB |
Output is correct |
3 |
Correct |
324 ms |
242272 KB |
Output is correct |
4 |
Correct |
102 ms |
26864 KB |
Output is correct |
5 |
Correct |
83 ms |
19364 KB |
Output is correct |
6 |
Correct |
229 ms |
165560 KB |
Output is correct |
7 |
Correct |
327 ms |
242424 KB |
Output is correct |
8 |
Correct |
382 ms |
242904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7372 KB |
Output is correct |
2 |
Correct |
4 ms |
7512 KB |
Output is correct |
3 |
Correct |
4 ms |
7372 KB |
Output is correct |
4 |
Correct |
5 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 |
5 ms |
7464 KB |
Output is correct |
9 |
Correct |
4 ms |
7372 KB |
Output is correct |
10 |
Correct |
4 ms |
7372 KB |
Output is correct |
11 |
Correct |
69 ms |
14752 KB |
Output is correct |
12 |
Correct |
51 ms |
11460 KB |
Output is correct |
13 |
Correct |
324 ms |
242272 KB |
Output is correct |
14 |
Correct |
102 ms |
26864 KB |
Output is correct |
15 |
Correct |
83 ms |
19364 KB |
Output is correct |
16 |
Correct |
229 ms |
165560 KB |
Output is correct |
17 |
Correct |
327 ms |
242424 KB |
Output is correct |
18 |
Correct |
382 ms |
242904 KB |
Output is correct |
19 |
Correct |
70 ms |
14784 KB |
Output is correct |
20 |
Correct |
54 ms |
11572 KB |
Output is correct |
21 |
Correct |
368 ms |
242340 KB |
Output is correct |
22 |
Correct |
96 ms |
26960 KB |
Output is correct |
23 |
Correct |
96 ms |
19380 KB |
Output is correct |
24 |
Correct |
263 ms |
165576 KB |
Output is correct |
25 |
Correct |
361 ms |
242332 KB |
Output is correct |
26 |
Correct |
353 ms |
242988 KB |
Output is correct |
27 |
Correct |
63 ms |
11820 KB |
Output is correct |
28 |
Correct |
117 ms |
19864 KB |
Output is correct |
29 |
Correct |
455 ms |
317520 KB |
Output is correct |
30 |
Correct |
299 ms |
163952 KB |
Output is correct |
31 |
Correct |
305 ms |
164140 KB |
Output is correct |
32 |
Correct |
507 ms |
317448 KB |
Output is correct |
33 |
Correct |
4 ms |
7372 KB |
Output is correct |
34 |
Correct |
4 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 |
5 ms |
7372 KB |
Output is correct |
38 |
Correct |
4 ms |
7500 KB |
Output is correct |
39 |
Correct |
4 ms |
7372 KB |
Output is correct |
40 |
Correct |
4 ms |
7500 KB |
Output is correct |
41 |
Correct |
4 ms |
7372 KB |
Output is correct |
42 |
Correct |
4 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7372 KB |
Output is correct |
2 |
Runtime error |
43 ms |
18052 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |