Submission #522510

# Submission time Handle Problem Language Result Execution time Memory
522510 2022-02-05T05:44:44 Z Leonardo_Paes Paths (BOI18_paths) C++17
23 / 100
65 ms 18804 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5+10, maxl = 1<<5 - 1;

int c[maxn];
vector<int> grafo[maxn];

long long dp[maxn][maxl];

long long solve(int u, int mask){
	if(dp[u][mask] != -1) return dp[u][mask];
	long long tot = 1;
	for(int v : grafo[u]) if(!(mask&c[v])) tot += solve(v, mask^c[v]);
	return dp[u][mask] = tot;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for(int i=1; i<=n; i++){
		cin >> c[i];
		c[i] = (1<<(c[i]-1));
	}
	for(int i=1; i<=m; i++){
		int u, v;
		cin >> u >> v;
		grafo[u].push_back(v);
		grafo[v].push_back(u);
	}
	long long ans = 0;
	memset(dp, -1, sizeof dp);
	for(int i=1; i<=n; i++) ans += solve(i, c[i]);
	cout << ans - n << "\n";
	return 0;
}

Compilation message

paths.cpp:4:38: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    4 | const int maxn = 1e5+10, maxl = 1<<5 - 1;
      |                                    ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 15180 KB Output is correct
2 Correct 7 ms 15188 KB Output is correct
3 Correct 7 ms 15180 KB Output is correct
4 Correct 11 ms 15084 KB Output is correct
5 Correct 7 ms 15180 KB Output is correct
6 Correct 7 ms 15180 KB Output is correct
7 Correct 7 ms 15116 KB Output is correct
8 Correct 7 ms 15180 KB Output is correct
9 Correct 6 ms 15180 KB Output is correct
10 Correct 6 ms 15180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 18804 KB Output is correct
2 Correct 54 ms 18760 KB Output is correct
3 Runtime error 9 ms 5956 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 15180 KB Output is correct
2 Correct 7 ms 15188 KB Output is correct
3 Correct 7 ms 15180 KB Output is correct
4 Correct 11 ms 15084 KB Output is correct
5 Correct 7 ms 15180 KB Output is correct
6 Correct 7 ms 15180 KB Output is correct
7 Correct 7 ms 15116 KB Output is correct
8 Correct 7 ms 15180 KB Output is correct
9 Correct 6 ms 15180 KB Output is correct
10 Correct 6 ms 15180 KB Output is correct
11 Correct 65 ms 18804 KB Output is correct
12 Correct 54 ms 18760 KB Output is correct
13 Runtime error 9 ms 5956 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15080 KB Output is correct
2 Incorrect 38 ms 16196 KB Output isn't correct
3 Halted 0 ms 0 KB -