Submission #586479

# Submission time Handle Problem Language Result Execution time Memory
586479 2022-06-30T10:17:12 Z Vanilla Simurgh (IOI17_simurgh) C++17
0 / 100
3000 ms 212 KB
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;
const int maxn = 7;

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
	vector <int> r (n - 1, 0);
	int m = u.size();
	auto check = [&] (vector <int> idx) {
		vector <vector <int> > ad(maxn);
		for (int i: idx) {
			ad[u[i]].push_back(v[i]);
			ad[v[i]].push_back(u[i]);
		}
		bitset <maxn> vis = 0;
		auto dfs = [&] (int u, auto&& dfs) -> void {
			vis[u] = 1;
			for (int v: ad[u]) {
				if (!vis[v]) dfs(v, dfs);
			}
			return;
		};
		dfs(0, dfs);
		for (int i = 0; i < n; i++){
			if (!vis[i]) return;
		}
		if (count_common_roads(idx) == n - 1) r = idx;
		
	};
	auto back = [&] (int step, vector <int> &used, auto&& back) -> void {
		if (step == m) {
			vector <int> idx;
			for (int i = 0; i < m; i++){
				if (used[i]) idx.push_back(i);
			}
			check(idx);
			return;
		}
		for (int i = step + 1; i < m; i++){
			if (!used[i]) {
				used[i] = 1;
				back(i, used, back);
				used[i] = 0;
			}
		}
		return;
	};
	back(0, *(new vector <int> (m, 0)), back);
	return r;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB correct
2 Execution timed out 3087 ms 212 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -