# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
731336 |
2023-04-27T10:27:18 Z |
esomer |
Pipes (CEOI15_pipes) |
C++17 |
|
1000 ms |
65536 KB |
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int MOD = 1e9 + 7;
int cnt = 1;
int DFS(int x, vector<vector<pair<int, int>>>& adj, vector<int>& vis, int edge){
vis[x] = cnt; int mn = cnt; cnt++;
for(pair<int, int> pr : adj[x]){
int node = pr.first;
if(pr.second == edge) continue;
if(vis[node] > 0){
mn = min(mn, vis[node]);
}else{
int val = DFS(node, adj, vis, pr.second);
mn = min(mn, val);
if(val > vis[x]){
cout << node + 1 << " " << x + 1 << endl;
}
}
}
return mn;
}
void solve(){
int n, m; cin >> n >> m;
vector<vector<pair<int, int>>> adj(n);
for(int i = 0; i < m; i++){
int u, v; cin >> u >> v; u--; v--;
adj[u].push_back({v, i}); adj[v].push_back({u, i});
}
vector<int> vis(n, 0);
for(int i = 0; i < n; i++){
if(!vis[i]){
DFS(i, adj, vis, -1);
}
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//~ int tt; cin >> tt;
int tt = 1;
for(int t = 1; t <= tt; t++){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1088 KB |
Output is correct |
2 |
Correct |
4 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
106 ms |
16396 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
230 ms |
22712 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
393 ms |
43080 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
656 ms |
50676 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
824 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1000 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
938 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
887 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |