Submission #881086

# Submission time Handle Problem Language Result Execution time Memory
881086 2023-11-30T14:41:04 Z OAleksa Paths (BOI18_paths) C++14
23 / 100
3000 ms 24652 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
const int maxn = 3e5 + 69;
int n, m, k, a[maxn], ans;
vector<int> g[maxn];
void dfs(int v, int nmask) {
	if (nmask == 0) {
		++ans;
		return;
	}
	for (auto u : g[v]) {
		if (nmask & (1 << a[u]))
			dfs(u, nmask ^ (1 << a[u]));
	}
}
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
   int tt = 1;
  	//cin >> tt;
   while (tt--) {
   	cin >> n >> m >> k;
   	for (int i = 1;i <= n;i++) {
   		cin >> a[i];
   		--a[i];
   	}
   	for (int i = 1;i <= m;i++) {
   		int a, b;
   		cin >> a >> b;
   		g[a].push_back(b);
   		g[b].push_back(a);
   	}
   	for (int mask = 1;mask < (1 << k);mask++) {
   		for (int i = 1;i <= n;i++) {
   			if (mask & (1 << a[i]))
   				dfs(i, mask ^ (1 << a[i]));
   		}
   	}
   	ans -= n;
   	cout << ans;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8792 KB Output is correct
2 Correct 2 ms 8796 KB Output is correct
3 Correct 2 ms 8796 KB Output is correct
4 Correct 2 ms 8796 KB Output is correct
5 Correct 2 ms 8796 KB Output is correct
6 Correct 3 ms 8792 KB Output is correct
7 Correct 2 ms 8796 KB Output is correct
8 Correct 2 ms 8796 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Correct 2 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 16208 KB Output is correct
2 Correct 1656 ms 15976 KB Output is correct
3 Correct 188 ms 24652 KB Output is correct
4 Correct 70 ms 20092 KB Output is correct
5 Correct 59 ms 20308 KB Output is correct
6 Execution timed out 3062 ms 21924 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8792 KB Output is correct
2 Correct 2 ms 8796 KB Output is correct
3 Correct 2 ms 8796 KB Output is correct
4 Correct 2 ms 8796 KB Output is correct
5 Correct 2 ms 8796 KB Output is correct
6 Correct 3 ms 8792 KB Output is correct
7 Correct 2 ms 8796 KB Output is correct
8 Correct 2 ms 8796 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Correct 2 ms 8796 KB Output is correct
11 Correct 345 ms 16208 KB Output is correct
12 Correct 1656 ms 15976 KB Output is correct
13 Correct 188 ms 24652 KB Output is correct
14 Correct 70 ms 20092 KB Output is correct
15 Correct 59 ms 20308 KB Output is correct
16 Execution timed out 3062 ms 21924 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Execution timed out 3084 ms 10844 KB Time limit exceeded
3 Halted 0 ms 0 KB -