답안 #54781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54781 2018-07-05T05:14:36 Z 2등은 나의 것^^(#2060) Potemkin cycle (CEOI15_indcyc) C++11
20 / 100
26 ms 2644 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 (MX[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);
		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:34: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:37: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);
             ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 620 KB Expected integer, but "no" found
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 620 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 620 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 620 KB Output is correct
2 Incorrect 3 ms 724 KB Expected integer, but "no" found
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 724 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1144 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1144 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1632 KB Output is correct
2 Correct 26 ms 2300 KB Output is correct
3 Incorrect 23 ms 2644 KB Expected integer, but "no" found
4 Halted 0 ms 0 KB -