답안 #125859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125859 2019-07-06T13:11:35 Z wilwxk Pipes (CEOI15_pipes) C++14
30 / 100
2996 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN=1e5+5;
vector<int> g[MAXN];
int pre[MAXN], low[MAXN];
int n, m, tempo;

void dfs(int cur, int p) {
	pre[cur]=low[cur]=++tempo;
	int cont=0;
	for(auto viz : g[cur]) {
		if(viz==p&&cont==0) {
			cont=1; continue;
		}
		if(!pre[viz]) {
			dfs(viz, cur);
			low[cur]=min(low[cur], low[viz]);
			if(low[viz]==pre[viz]) printf("%d %d\n", cur, viz);
		}
		low[cur]=min(low[cur], pre[viz]);
	}
	// printf("%d >> %d %d\n", cur, pre[cur], low[cur]);
}

int main() {
	scanf("%d %d", &n, &m);
	for(int i=1; i<=m; i++) {
		int a, b; scanf("%d %d", &a, &b);
		g[a].push_back(b); g[b].push_back(a);
	}

	for(int i=1; i<=n; i++) if(!pre[i]) dfs(i, i);

}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:29:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d %d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 3324 KB Output is correct
2 Correct 9 ms 3064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 181 ms 11900 KB Output is correct
2 Correct 176 ms 11248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 332 ms 14712 KB Output is correct
2 Runtime error 404 ms 19248 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 623 ms 25668 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 938 ms 31516 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1726 ms 54128 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2299 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2711 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2996 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -