Submission #243894

# Submission time Handle Problem Language Result Execution time Memory
243894 2020-07-02T05:24:25 Z errorgorn Pipes (CEOI15_pipes) C++14
30 / 100
2713 ms 65540 KB
//雪花飄飄北風嘯嘯
//天地一片蒼茫
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;
 
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
 
ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}
 
#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
 
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
 
int n,m;
vector<int> al[100005];
int dfs_time[100005]; ///first time to reach vertex
int low[100005]; ///lowest time vertex it can reach with 1 backtrack
int dfs_counter=1;
void dfs(int i,int j){ ///j is parent of i
	dfs_time[i]=low[i]=dfs_counter++;
	
	bool vis_par=false;
	
	for (vector<int>::iterator it=al[i].begin();it!=al[i].end();it++){
		if (!dfs_time[*it]){ ///uninitialized vertex
			dfs(*it,i);
			low[i]=min(low[i],low[*it]);
			
			if (low[*it]>dfs_time[i]){
				cout<<*it<<" "<<i<<endl;
			}
		}
		else if (*it!=j || vis_par){ ///make sure it is a back edge
			low[i]=min(low[i],dfs_time[*it]);
		}
		else{
			vis_par=true;
		}
	}
}
 
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	
	int a,b;
	rep(x,0,m){
		cin>>a>>b;
		
		al[a].push_back(b);
		al[b].push_back(a);
	}
	
	rep(x,1,n+1) if (!dfs_time[x]) dfs(x,-1);
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3328 KB Output is correct
2 Correct 9 ms 3072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 12344 KB Output is correct
2 Correct 127 ms 11384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 245 ms 15608 KB Output is correct
2 Runtime error 289 ms 30072 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
# Verdict Execution time Memory Grader output
1 Runtime error 478 ms 26360 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 821 ms 31480 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1529 ms 65536 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1887 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2347 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2713 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -