# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109987 |
2019-05-08T14:13:36 Z |
someone_aa |
Pipes (CEOI15_pipes) |
C++17 |
|
3832 ms |
13132 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 U[2][maxn];
int find(int t, int x){
return x==U[t][x] ? x : U[t][x]=find(t,U[t][x]);
}
void unite(int t, int x, int y){
if(find(t,x)==find(t,y)) return;
U[t][U[t][y]]=U[t][x];
}
int br;
bool visited[maxn];
void dfs(int node, int p) {
tin[node] = br++;
low[node] = tin[node];
visited[node] = true;
for(int i:g[node]) {
if(i == p) continue;
if(visited[i]) {
low[node] = min(low[node], tin[i]);
}
else {
dfs(i, node);
low[node] = min(low[node], low[i]);
if(low[i] > tin[node]) {
cout<<i<<" "<<node<<"\n";
}
}
}
}
int main() {
cin>>n>>m;
int u, v;
for(int i=1; i<=n; i++) U[0][i]=U[1][i]=i;
for(int i=1; i<=m; i++){
int u, v; cin>>u>>v;
if(find(0,u)==find(0,v)){
if(find(1,u)==find(1,v)) continue;
unite(1,u,v);
}
else unite(0,u,v);
g[u].push_back(v);
g[v].push_back(u);
}
for(int i=1;i<=n;i++) {
if(!visited[i]) {
dfs(i, -1);
}
}
return 0;
}
Compilation message
pipes.cpp: In function 'int main()':
pipes.cpp:46:9: warning: unused variable 'u' [-Wunused-variable]
int u, v;
^
pipes.cpp:46:12: warning: unused variable 'v' [-Wunused-variable]
int 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 |
10 ms |
3200 KB |
Output is correct |
2 |
Incorrect |
17 ms |
2944 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
295 ms |
3020 KB |
Output is correct |
2 |
Incorrect |
284 ms |
2936 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
512 ms |
3700 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1000 ms |
5156 KB |
Output is correct |
2 |
Correct |
722 ms |
4888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1154 ms |
10056 KB |
Output is correct |
2 |
Incorrect |
984 ms |
7112 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1993 ms |
11060 KB |
Output is correct |
2 |
Incorrect |
1860 ms |
8616 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2645 ms |
13132 KB |
Output is correct |
2 |
Incorrect |
2402 ms |
9044 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3333 ms |
13128 KB |
Output is correct |
2 |
Incorrect |
3047 ms |
9044 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3832 ms |
12624 KB |
Output is correct |
2 |
Correct |
3815 ms |
10352 KB |
Output is correct |