# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
874354 |
2023-11-16T17:43:29 Z |
AHOKA |
Pipes (CEOI15_pipes) |
C++14 |
|
2400 ms |
65536 KB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#define threesum cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#define all(a) a.begin(), a.end()
#define lmx 9223372036854775807;
//#define mod 1000000007
#define F first
#define S second
vector<int> adj[100010];
int par[100010], par2[100010], sz[100010], n, m, mxsz, cnt, seen[100010], d[100010];
int getpar(int v){
return ((par[v]!=v) ? par[v] = getpar(par[v]) : v);
}
int getpar2(int v){
return ((par2[v]!=v) ? par2[v] = getpar2(par2[v]) : v);
}
bool merge(int u, int v){
int u1 = getpar(u), v1 = getpar(v);
if(u1 == v1){
int u2 = getpar2(u), v2 = getpar2(v);
if(u2 == v2) return 0;
par2[u2] = v2;
return 1;
}
par[u1] = v1;
return 1;
}
void dfs(int v, int p){
seen[v]=seen[p]+1;
d[v]=seen[v];
for(auto u:adj[v]){
if(u==p)continue;
if(!seen[u])dfs(u, v);
d[v]=min(d[v], d[u]);
}
if(d[v]==seen[v]&&p!=0)cout << v << " " << p << "\n";
}
int main() {
cin >> n >> m;
for(int i=1;i<=n;i++)par[i]=i, par2[i]=i;
for(int i=0;i<m;i++){
int u, v;cin >> v >> u;
if(merge(u, v))adj[v].push_back(u), adj[u].push_back(v);
}
for(int i=1;i<=n;i++)dfs(i, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4444 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5132 KB |
Output is correct |
2 |
Incorrect |
7 ms |
4700 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
9504 KB |
Output is correct |
2 |
Incorrect |
196 ms |
10068 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
348 ms |
13148 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
615 ms |
19380 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
742 ms |
27328 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1172 ms |
38020 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1554 ms |
47716 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1914 ms |
57748 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2400 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |