# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
839675 |
2023-08-30T12:04:56 Z |
kyaruru |
Pipes (CEOI15_pipes) |
C++17 |
|
815 ms |
59872 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
vector<int> uf1(100001),uf2(100001),tin(100001,-1),low(100001,-1);
vector<int> adj[100001];
bool vi[100001];
int t=0;
int find(int x,int p) {
if(p==1){
if (x == uf1[x]) return x;
else return uf1[x] = find(uf1[x],p);
}else{
if (x == uf2[x]) return x;
else return uf2[x] = find(uf2[x],p);
}
}
void unite(int x, int y,int p){
x = find(x,p);
y = find(y,p);
if(p==1) uf1[x] = y;
else uf2[x] = y;
}
void dfs(int x,int p=-1){
vi[x]=true;
tin[x]=low[x]=t++;
for(int u:adj[x]){
if(p==u) continue;
if(vi[u]) low[x]=min(low[x],tin[u]);
else{
dfs(u,x);
low[x]=min(low[x],low[u]);
if(low[u]>tin[x]) cout<<x<<" "<<u<<"\n";
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
iota(uf1.begin(),uf1.end(),0);
iota(uf2.begin(),uf2.end(),0);
int a,b;
cin>>a>>b;
for(int i=0; i<b; i++){
int x,y;
cin>>x>>y;
if(find(x,1)!=find(y,1)){
unite(x,y,1);
adj[x].push_back(y);
adj[y].push_back(x);
}
else if(find(x,2)!=find(y,2)){
unite(x,y,2);
adj[x].push_back(y);
adj[y].push_back(x);
}
}
for(int i=1; i<=a; i++){
if(!vi[i]) dfs(i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4180 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4180 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4564 KB |
Output is correct |
2 |
Incorrect |
4 ms |
4436 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
4532 KB |
Output is correct |
2 |
Incorrect |
68 ms |
4376 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
5028 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
6488 KB |
Output is correct |
2 |
Runtime error |
167 ms |
19880 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
10400 KB |
Output is correct |
2 |
Runtime error |
242 ms |
25712 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
413 ms |
11336 KB |
Output is correct |
2 |
Runtime error |
411 ms |
42300 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
604 ms |
38624 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
695 ms |
47100 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
815 ms |
59872 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |