답안 #34459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
34459 2017-11-11T13:45:33 Z bnahmad15 Pipes (CEOI15_pipes) C++14
10 / 100
407 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 30003;
bitset< N > vis , vis2[N] , vis3[N];
vector< short > adj[N];
short dfs_low[N], dfs_num[N], num = 0 ;
int n , m , u , v , ans = 0 ;

void DFS(short node,short prnt){
	vis[node]=true;
	dfs_low[node]=dfs_num[node]=num++;
	for (short i = 0;i<adj[node].size();i++){
		if (adj[node][i]==prnt)
			continue;
		if (vis[adj[node][i]]){
			dfs_low[node]=min(dfs_low[node],dfs_num[adj[node][i]]);
		}
		else {
			DFS(adj[node][i],node);
			if (dfs_num[node] < dfs_low[adj[node][i]] && !vis3[node][adj[node][i]]){
				printf("%d %d\n",node,adj[node][i]);
			}
			dfs_low[node]=min(dfs_low[node],dfs_low[adj[node][i]]);
		}
	}
}
int main(){
	
	scanf("%d%d",&n,&m);
	for (int i = 0 ; i <m;i++){
		scanf("%d%d",&u,&v);
		if (vis2[u][v]){
			vis3[u][v]=vis3[v][u]=true;
			continue;
		}
		vis2[u][v]=vis2[v][u]=true;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1 ; i <= n;i++)
		if (!vis[i])
			DFS(i,-1);
	return 0;
}

Compilation message

pipes.cpp: In function 'void DFS(short int, short int)':
pipes.cpp:12:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (short i = 0;i<adj[node].size();i++){
                   ~^~~~~~~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:29: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:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&u,&v);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1408 KB Output is correct
2 Correct 2 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 20 ms 18048 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 228 ms 31280 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 407 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 75 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 8 ms 1836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 1808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 1920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -