답안 #40442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40442 2018-02-01T13:10:10 Z Pajaraja Pipes (CEOI15_pipes) C++14
50 / 100
601 ms 13400 KB
#include <bits/stdc++.h>
using namespace std;
vector<unsigned short> g[30007];
unsigned short d[30007];
unsigned short dfs(int s,int du,int f)
{
	unsigned short x=30008;
	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]]==30008)
		{
			unsigned short y=dfs(g[s][i],du+1,s);
			if(y>du) printf("%d %d\n",s,g[s][i]);
			x=fmin(x,y);
		}
		else x=fmin(x,d[g[s][i]]); 
	}
	return x;
}
int main()
{
	int n,m;
	fill(d,d+30007,30008);
	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]==30008) dfs(i,0,-1);
}

Compilation message

pipes.cpp: In function 'short unsigned int 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:31: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:35: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 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1536 KB Output is correct
2 Correct 6 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 150 ms 5368 KB Output is correct
2 Correct 150 ms 4908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 7188 KB Output is correct
2 Correct 331 ms 9116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 601 ms 13400 KB Output is correct
2 Correct 415 ms 11620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 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 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 1948 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 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 4 ms 1920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -