Submission #54779

# Submission time Handle Problem Language Result Execution time Memory
54779 2018-07-05T05:09:59 Z 2등은 나의 것^^(#2060) Potemkin cycle (CEOI15_indcyc) C++11
20 / 100
22 ms 1556 KB
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>edge[1212];
bool is_gone_dfs1[1212];
int depth[1212], MX[1212], ck[1212];
void dfs1(int w,int dep,int bef) {
	depth[w] = dep;
	is_gone_dfs1[w] = 1;
	for (int i = 0; i < edge[w].size(); i++) {
		int next = edge[w][i];
		if (is_gone_dfs1[next]) {
			if(next==bef || depth[next] > depth[w])continue;
			if (MX[w] < depth[next])MX[w] = depth[next];
			continue;
		}
		dfs1(next, dep + 1, w);
	}
}
int stdep;
int dfs2(int w) {
	if (ck[w]) { printf("%d ", w); return 1; }
	for (int i = 0; i < edge[w].size(); i++) {
		int next = edge[w][i];
		if (depth[next] - depth[w] != 1)continue;
		if (MX[next] && (!ck[next] && MX[next] >= stdep))continue;
		if (dfs2(next)) { printf("%d ", w); return 1; }
	}
	return 0;
}
int main() {
	int n, m; scanf("%d%d", &n, &m);
	int i, j;
	for (i = 0; i < m; i++) {
		int s, e; scanf("%d%d", &s, &e);
		if (s == e)while (1);
		edge[s].push_back(e);
		edge[e].push_back(s);
	}
	for (i = 1; i <= n; i++) {
		if (is_gone_dfs1[i])continue;
		dfs1(i, 1, -1);
	}
	for (i = 1; i <= n; i++) {
		for (j = 0; j < edge[i].size(); j++) ck[edge[i][j]] = (depth[edge[i][j]] - depth[i] >= 3);
		stdep = depth[i];
		if (dfs2(i)) return 0;
		for (j = 0; j < edge[i].size(); j++) ck[edge[i][j]] = 0;
	}
	printf("no");
	return 0;
}

Compilation message

indcyc.cpp: In function 'void dfs1(int, int, int)':
indcyc.cpp:11:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < edge[w].size(); i++) {
                  ~~^~~~~~~~~~~~~~~~
indcyc.cpp: In function 'int dfs2(int)':
indcyc.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < edge[w].size(); i++) {
                  ~~^~~~~~~~~~~~~~~~
indcyc.cpp: In function 'int main()':
indcyc.cpp:46:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (j = 0; j < edge[i].size(); j++) ck[edge[i][j]] = (depth[edge[i][j]] - depth[i] >= 3);
               ~~^~~~~~~~~~~~~~~~
indcyc.cpp:49:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (j = 0; j < edge[i].size(); j++) ck[edge[i][j]] = 0;
               ~~^~~~~~~~~~~~~~~~
indcyc.cpp:33:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n, m; scanf("%d%d", &n, &m);
            ~~~~~^~~~~~~~~~~~~~~~
indcyc.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int s, e; scanf("%d%d", &s, &e);
             ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 496 KB Wrong adjacency
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 496 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 664 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 664 KB Wrong answer on graph without induced cycle
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 664 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1152 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1152 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1556 KB Wrong adjacency
2 Halted 0 ms 0 KB -