Submission #34378

# Submission time Handle Problem Language Result Execution time Memory
34378 2017-11-10T19:23:52 Z mohammad_kilani Pipes (CEOI15_pipes) C++14
30 / 100
3509 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#define mod 1000007
#define oo 2000000000
const int M = 2000010 , N = 100001;
bitset< N > vis;
vector< short > g[N];
short dfs_low[N], dfs_time[N], num = 0 ;
int n , m , u , v;

void DFS(short node,short prnt){
	vis[node] = true;
	dfs_low[node] = dfs_time[node] = num++;
	for(short i=0;i<g[node].size();i++){
		if(g[node][i] == prnt) continue;
		if(vis[g[node][i]]){
			dfs_low[node] = min(dfs_low[node],dfs_time[g[node][i]]);
		}
		else{
			DFS(g[node][i],node);
			dfs_low[node] = min(dfs_low[node],dfs_low[g[node][i]]);
			if(dfs_time[node] < dfs_low[g[node][i]]){
				printf("%d %d\n",node,g[node][i]);
			}
		}
	}
}

int main() {
	//freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(short i=1;i<=n;i++){
		if(vis[i] == false) DFS(i,-1);
	}
	return 0;
}

Compilation message

pipes.cpp: In function 'void DFS(short int, short int)':
pipes.cpp:14:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(short i=0;i<g[node].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:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&u,&v);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Incorrect 4 ms 2688 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3072 KB Output is correct
2 Incorrect 7 ms 2816 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 148 ms 6916 KB Output is correct
2 Correct 140 ms 6408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 299 ms 8904 KB Output is correct
2 Correct 342 ms 10748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 615 ms 14992 KB Output is correct
2 Correct 475 ms 13268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1061 ms 28584 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1708 ms 49600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2330 ms 62100 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2710 ms 63596 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3509 ms 65536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -