# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
874362 |
2023-11-16T18:00:07 Z |
AHOKA |
Pipes (CEOI15_pipes) |
C++14 |
|
2408 ms |
51532 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<pair<int, int>> adj[100001];
int par[100001], par2[100001], edges, n, m, seen[100001], d[100001];
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, edges++;
return 1;
}
par[u1] = v1, edges++;
return 1;
}
void dfs(int v, int p, int pid){
seen[v]=seen[p]+1;
d[v]=seen[v];
for(auto [u, id]:adj[v]){
if(u==p && pid==id)continue;
if(!seen[u])dfs(u, v, id);
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, edges}), adj[u].push_back({v, edges});
}
for(int i=1;i<=n;i++)if(!seen[i])dfs(i, 0, 0);
}
Compilation message
pipes.cpp: In function 'void dfs(int, int, int)':
pipes.cpp:41:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
41 | for(auto [u, id]:adj[v]){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4184 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4852 KB |
Output is correct |
2 |
Correct |
7 ms |
4456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
214 ms |
4376 KB |
Output is correct |
2 |
Correct |
211 ms |
4368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
394 ms |
5204 KB |
Output is correct |
2 |
Correct |
418 ms |
4736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
571 ms |
6996 KB |
Output is correct |
2 |
Correct |
490 ms |
6228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
734 ms |
12476 KB |
Output is correct |
2 |
Runtime error |
660 ms |
18176 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1152 ms |
13620 KB |
Output is correct |
2 |
Runtime error |
1220 ms |
27120 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1547 ms |
16040 KB |
Output is correct |
2 |
Runtime error |
1467 ms |
31920 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1984 ms |
15836 KB |
Output is correct |
2 |
Runtime error |
1916 ms |
37560 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2370 ms |
15468 KB |
Output is correct |
2 |
Runtime error |
2408 ms |
51532 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |