Submission #403811

# Submission time Handle Problem Language Result Execution time Memory
403811 2021-05-13T13:33:42 Z saleh Potemkin cycle (CEOI15_indcyc) C++17
40 / 100
1 ms 204 KB
#include <bits/stdc++.h>


using namespace std;


const int MAXN = 10 + 1;















int n, m;
vector<int> g[MAXN];
bitset<MAXN> mark, mirk;

int dfs(int v) {
	int res = 1, deg = 0;
	mirk[v] = true;
	for (auto i : g[v]) if (mark[i]) deg++;
	if (deg != 2) res = -1;
	for (auto i : g[v]) if (mark[i] && !mirk[i]) {
		int tmp = dfs(i);
		if (~tmp && ~res) res += tmp;
	}
	return res;
}
void ofs(int v) {
	cout << v + 1 << ' ';
	mirk[v] = true;
	for (auto i : g[v]) if (mark[i] && !mirk[i]) ofs(i);
}



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> m;
	if (n > MAXN) return 0;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[--a].push_back(--b), g[b].push_back(a);
	}
	for (int i = 0; i < (1 << n); i++) {
		mirk.reset();
		mark.reset();
		vector<int> vec;
		for (int j = 0; j < n; j++) if (i & (1 << j)) {
			vec.push_back(j);
			mark[j] = true;
		}
		if (vec.size() > 3) if (dfs(vec.back()) == vec.size()) {
			mirk.reset();
			ofs(vec.back());
			return 0;
		}
	}
	cout << "no";
	return 0;
}

Compilation message

indcyc.cpp: In function 'int main()':
indcyc.cpp:64:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |   if (vec.size() > 3) if (dfs(vec.back()) == vec.size()) {
      |                           ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Too short sequence
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Too short sequence
2 Incorrect 1 ms 204 KB Unexpected end of file - token expected
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Too short sequence
2 Incorrect 1 ms 204 KB Unexpected end of file - token expected
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Too short sequence
2 Correct 1 ms 204 KB Too short sequence
3 Incorrect 1 ms 204 KB Unexpected end of file - token expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Too short sequence
2 Incorrect 1 ms 204 KB Unexpected end of file - token expected
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Too short sequence
2 Incorrect 1 ms 204 KB Unexpected end of file - token expected
3 Halted 0 ms 0 KB -