Submission #36934

# Submission time Handle Problem Language Result Execution time Memory
36934 2017-12-19T08:48:30 Z aome Potemkin cycle (CEOI15_indcyc) C++14
70 / 100
216 ms 8092 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1005;

int n, m;
int nxt[N][N];
bool E[N][N];
bool finish[N][N];

void dfs(int x, int y) {
	for (int i = 1; i <= n; ++i) {
		if (E[y][i] && !E[x][i] && i != x && !finish[y][i]) {
			if (nxt[y][i]) {
				int curx = x, cury = y;
				while (curx != y && cury != i) {
					cout << cury << ' ';
					int tmp = nxt[curx][cury];
					cury = curx, curx = tmp;
				}
				cout << cury;
				exit(0);
			}
			else nxt[y][i] = nxt[i][y] = x, dfs(y, i);
		}
	}
	finish[x][y] = finish[y][x] = 1;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int u, v; cin >> u >> v;
		E[u][v] = E[v][u] = 1;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (!E[i][j] || nxt[i][j]) continue;
			nxt[i][j] = nxt[j][i] = i, dfs(i, j);
		}
	}
	cout << "no";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 8092 KB Output is correct
2 Correct 0 ms 8092 KB Output is correct
3 Correct 0 ms 8092 KB Output is correct
4 Correct 0 ms 8092 KB Output is correct
5 Correct 0 ms 8092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 8092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 8092 KB Output is correct
2 Correct 0 ms 8092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 8092 KB Wrong adjacency
# Verdict Execution time Memory Grader output
1 Correct 0 ms 8092 KB Output is correct
2 Correct 0 ms 8092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8092 KB Output is correct
2 Incorrect 3 ms 8092 KB Wrong adjacency
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8092 KB Output is correct
2 Correct 3 ms 8092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 8092 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 8092 KB Output is correct
2 Correct 49 ms 8092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 8092 KB Output is correct
2 Correct 96 ms 8092 KB Output is correct
3 Correct 103 ms 8092 KB Output is correct
4 Correct 216 ms 8092 KB Output is correct