Submission #863414

# Submission time Handle Problem Language Result Execution time Memory
863414 2023-10-20T07:41:30 Z maks007 Paths (BOI18_paths) C++14
0 / 100
3000 ms 7768 KB
// Bismi Allah
#include "bits/stdc++.h"

using namespace std;

#define int long long

signed main () {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m, k, ans = 0;
	cin >> n >> m >> k;
	vector <int> color(n), g[n], used(n);
	set <int> colorUsed;
	function <void(int, int, int)> dfs=[&](int v, int depth, const int &need) {
		colorUsed.insert(color[v]);
		if(depth == need) {
			ans += (colorUsed.size() == need);
			colorUsed.erase(color[v]);
			return;
		}
		used[v] = 1;	
		for(auto u : g[v] ) {
			if(!used[u]) dfs(u, depth + 1, need);
		}
		used[v]=0;
		colorUsed.erase(color[v]);
	};
	
	for(int i = 0; i < n; i ++) cin >> color[i];
	for(int i = 0; i < m; i ++) {
		int u, v;
		cin >> u >> v;
		u --, v --;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	/*for(int dist = 2; dist <= k; dist ++) {
		for(int i = 0; i < n; i ++) {
			dfs(i, 1, dist);
			cout << "\n";
		}
	}*/
	dfs(0, 0, 4);
	cout << ans;
	return 0;
}

Compilation message

paths.cpp: In lambda function:
paths.cpp:18:29: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'const long long int' [-Wsign-compare]
   18 |    ans += (colorUsed.size() == need);
      |            ~~~~~~~~~~~~~~~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3052 ms 7768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -