답안 #40425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40425 2018-02-01T12:55:52 Z Pajaraja Pipes (CEOI15_pipes) C++14
30 / 100
635 ms 23384 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> g[30007];
int d[30007],minx[30007];
void dfs(int s,int du,int f)
{
	minx[s]=10000007;
	d[s]=du;
	int cnt=0;
	for(int i=0;i<g[s].size();i++)
	{
		if(cnt==0 && g[s][i]==f)
		{
			cnt++;
			continue;
		}
		if(d[g[s][i]]==-1)
		{
			dfs(g[s][i],du+1,s);
			if(minx[g[s][i]]>du) printf("%d %d\n",s,g[s][i]);
			minx[s]=fmin(minx[s],minx[g[s][i]]);
		}
		else minx[s]=fmin(minx[s],d[g[s][i]]); 
	}
}
int main()
{
	int n,m;
	fill(d,d+30007,-1);
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int t1,t2;
		scanf("%d%d",&t1,&t2);
		g[t1].push_back(t2);
		g[t2].push_back(t1);
	}
	for(int i=1;i<=n;i++) if(d[i]==-1) dfs(i,0,-1);
}

Compilation message

pipes.cpp: In function 'void dfs(int, int, int)':
pipes.cpp:10:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<g[s].size();i++)
              ~^~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:30: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:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&t1,&t2);
   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1664 KB Output is correct
2 Correct 6 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 159 ms 9204 KB Output is correct
2 Correct 155 ms 8568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 321 ms 12644 KB Output is correct
2 Runtime error 368 ms 17060 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 635 ms 23384 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 4 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -