# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109983 |
2019-05-08T14:03:05 Z |
someone_aa |
Pipes (CEOI15_pipes) |
C++17 |
|
5000 ms |
7272 KB |
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
vector<int>g[maxn];
int n, m;
int tin[maxn], low[maxn];
int uparent[maxn][2];
int usize[maxn][2];
int root(int x, int d) {
while(x != uparent[x][d]) {
x = uparent[x][d];
}
return x;
}
void unite(int x, int y, int d) {
x = root(x, d);
y = root(y, d);
if(x == y) return;
uparent[x][d] = y;
usize[y][d] += usize[x][d];
}
int br;
bool visited[maxn];
set<pair<int,int> > result;
int timer;
void dfs(int v, int p = -1) {
visited[v] = true;
tin[v] = low[v] = timer++;
for (int to : g[v]) {
if (to == p) continue;
if (visited[to]) {
low[v] = min(low[v], tin[to]);
} else {
dfs(to, v);
low[v] = min(low[v], low[to]);
if (low[to] > tin[v])
cout<<v+1<<" "<<to+1<<"\n";
}
}
}
int main() {
cin>>n>>m;
int u, v;
for(int i=0;i<n;i++) {
usize[i][0] = usize[i][1] = 1;
uparent[i][0] = uparent[i][1] = i;
}
for(int i=0;i<m;i++) {
cin>>u>>v;
u--; v--;
if(root(u, 1) == root(v, 1)) continue;
if(root(u,0) != root(v,0)) {
unite(u, v, 0);
g[u].pb(v);
g[v].pb(u);
}
else {
unite(u, v, 1);
g[u].pb(v);
g[v].pb(u);
}
}
memset(tin,-1,sizeof(tin));
memset(low,-1,sizeof(low));
for(int i=0;i<n;i++) {
if(!visited[i]) {
dfs(i, -1);
}
}
for(auto i:result) {
cout<<i.first+1<<" "<<i.second+1<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3456 KB |
Output is correct |
2 |
Incorrect |
4 ms |
3456 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
3960 KB |
Output is correct |
2 |
Incorrect |
15 ms |
3712 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1565 ms |
3820 KB |
Output is correct |
2 |
Incorrect |
466 ms |
3704 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5066 ms |
3328 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5006 ms |
4228 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5037 ms |
6132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5045 ms |
6384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5057 ms |
7080 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5067 ms |
7272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5056 ms |
6956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |