Submission #518384

# Submission time Handle Problem Language Result Execution time Memory
518384 2022-01-23T15:55:43 Z Ierus Paths (BOI18_paths) C++17
70 / 100
480 ms 167204 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<<4)];
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 7372 KB Output is correct
3 Correct 4 ms 7316 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7372 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 4 ms 7372 KB Output is correct
8 Correct 4 ms 7372 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 64 ms 12880 KB Output is correct
2 Correct 52 ms 11236 KB Output is correct
3 Correct 309 ms 129652 KB Output is correct
4 Correct 97 ms 19440 KB Output is correct
5 Correct 75 ms 15556 KB Output is correct
6 Correct 201 ms 90372 KB Output is correct
7 Correct 285 ms 129600 KB Output is correct
8 Correct 291 ms 130292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7372 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 4 ms 7316 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7372 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 4 ms 7372 KB Output is correct
8 Correct 4 ms 7372 KB Output is correct
9 Correct 4 ms 7372 KB Output is correct
10 Correct 4 ms 7372 KB Output is correct
11 Correct 64 ms 12880 KB Output is correct
12 Correct 52 ms 11236 KB Output is correct
13 Correct 309 ms 129652 KB Output is correct
14 Correct 97 ms 19440 KB Output is correct
15 Correct 75 ms 15556 KB Output is correct
16 Correct 201 ms 90372 KB Output is correct
17 Correct 285 ms 129600 KB Output is correct
18 Correct 291 ms 130292 KB Output is correct
19 Correct 73 ms 12864 KB Output is correct
20 Correct 73 ms 11272 KB Output is correct
21 Correct 281 ms 129636 KB Output is correct
22 Correct 91 ms 19404 KB Output is correct
23 Correct 74 ms 15668 KB Output is correct
24 Correct 212 ms 90424 KB Output is correct
25 Correct 327 ms 129552 KB Output is correct
26 Correct 321 ms 130296 KB Output is correct
27 Correct 65 ms 11332 KB Output is correct
28 Correct 91 ms 15828 KB Output is correct
29 Correct 480 ms 167204 KB Output is correct
30 Correct 271 ms 88856 KB Output is correct
31 Correct 264 ms 89056 KB Output is correct
32 Correct 409 ms 167148 KB Output is correct
33 Correct 4 ms 7372 KB Output is correct
34 Correct 4 ms 7372 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 7372 KB Output is correct
38 Correct 4 ms 7372 KB Output is correct
39 Correct 4 ms 7372 KB Output is correct
40 Correct 5 ms 7372 KB Output is correct
41 Correct 4 ms 7372 KB Output is correct
42 Correct 6 ms 7372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 14772 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -