Submission #413821

# Submission time Handle Problem Language Result Execution time Memory
413821 2021-05-29T14:45:58 Z ak2006 Paths (BOI18_paths) C++14
23 / 100
3000 ms 101844 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vc = vector<char>;
using vvc = vector<vc>;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
void setIO()
{
	fast;
}
int n = 3e5 + 5,m = 3e5 + 5,k = 5;
vvi adj(n);
vi col(n);
vvl dp(n,vl(1<<k));
void dfs(int u,int mask)
{
	int mask2 = mask |  (1<<col[u]);
	dp[u][mask] = 1;
	for (int v:adj[u]){
		if ((mask2 & (1<<col[v])))continue;
		dfs(v,mask2);
		dp[u][mask] += dp[v][mask2];
	}
}
int main()
{
	setIO();
	cin>>n>>m>>k;
	for (int i = 1;i<=n;i++){cin>>col[i];col[i]--;}
	while (m--){
		int u,v;
		cin>>u>>v;
		adj[u].pb(v),adj[v].pb(u);
	}
	ll ans = 0;
	for (int i = 1;i<=n;i++){
		for (int mask = 0;mask < (1<<k);mask++){
			if (mask & (1<<col[i]))continue;
			dfs(i,mask);
		}
	}
	for (int i = 1;i<=n;i++)ans += dp[i][0] - 1;
	cout<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 60 ms 95356 KB Output is correct
2 Correct 61 ms 95316 KB Output is correct
3 Correct 61 ms 95348 KB Output is correct
4 Correct 60 ms 95380 KB Output is correct
5 Correct 62 ms 95428 KB Output is correct
6 Correct 67 ms 95416 KB Output is correct
7 Correct 63 ms 95316 KB Output is correct
8 Correct 60 ms 95384 KB Output is correct
9 Correct 61 ms 95388 KB Output is correct
10 Correct 63 ms 95416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3059 ms 101844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 60 ms 95356 KB Output is correct
2 Correct 61 ms 95316 KB Output is correct
3 Correct 61 ms 95348 KB Output is correct
4 Correct 60 ms 95380 KB Output is correct
5 Correct 62 ms 95428 KB Output is correct
6 Correct 67 ms 95416 KB Output is correct
7 Correct 63 ms 95316 KB Output is correct
8 Correct 60 ms 95384 KB Output is correct
9 Correct 61 ms 95388 KB Output is correct
10 Correct 63 ms 95416 KB Output is correct
11 Execution timed out 3059 ms 101844 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 95408 KB Output is correct
2 Execution timed out 3069 ms 97188 KB Time limit exceeded
3 Halted 0 ms 0 KB -