Submission #680090

# Submission time Handle Problem Language Result Execution time Memory
680090 2023-01-09T22:12:07 Z GusterGoose27 Potemkin cycle (CEOI15_indcyc) C++11
40 / 100
178 ms 2052 KB
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;

const int MAXN = 1000;
int n, m;
vector<int> edges[MAXN];
int adj[MAXN];
bool vis[MAXN];

bool make_ans(int s, int cur, int msk = 0, int num = 1) {
	msk |= (1 << cur);
	for (int nxt: edges[cur]) {
		if ((1 << nxt) & msk) continue;
		if ((adj[nxt] & msk) == (1 << cur)) {
			if (make_ans(s, nxt, msk, num+1)) {
				cout << (1+cur);
				if (cur != s) cout << ' ';
				return 1;
			}
		}
		else if ((adj[nxt] & msk) == ((1 << cur) | (1 << s))) {
			if (num >= 3) {
				cout << (1+nxt) << ' ' << (1+cur) << ' ';
				return 1;
			}
		}
	}
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		edges[x].push_back(y);
		edges[y].push_back(x);
		adj[x] |= (1 << y);
		adj[y] |= (1 << x);
	}
	for (int i = 0; i < n; i++) {
		if (make_ans(i, i)) return 0;
	}
	cout << "no\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 352 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Wrong answer on graph without induced cycle
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1252 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 724 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 178 ms 2052 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -