# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
948769 |
2024-03-18T13:36:58 Z |
Aiperiii |
Pipes (CEOI15_pipes) |
C++14 |
|
2609 ms |
62240 KB |
#include <bits/stdc++.h>
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=1e5+5;
int p[2][N],vis[N],tin[N],low[N];
vector <int> g[N];
int find_set(int i,int v){
if(p[i][v]==v)return v;
return p[i][v]=find_set(i,p[i][v]);
}
bool union_set(int i,int u,int v){
if(find_set(i,u)==find_set(i,v))return false;
p[i][u]=v;
return true;
}
int t=0;
void dfs(int v,int p){
vis[v]=1;
t++;
tin[v]=t;
low[v]=t;
for(auto to : g[v]){
if(to!=p){
if(vis[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<<" "<<to<<"\n";
}
}
}
}
}
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
p[0][i]=i;
p[1][i]=i;
}
for(int i=0;i<m;i++){
int u,v;
cin>>u>>v;
if(union_set(0,u,v)){
g[u].pb(v);
g[v].pb(u);
}
else if(union_set(1,u,v)){
g[u].pb(v);
g[v].pb(u);
}
}
for(int i=1;i<=n;i++){
sort(all(g[i]));
for(int j=1;j<g[i].size();j++){
if(g[i][j]==g[i][j-1]){
g[i][j]=0;
g[i][j-1]=0;
}
}
}
for(int i=1;i<=n;i++){
if(!vis[i])dfs(i,0);
}
}
Compilation message
pipes.cpp: In function 'int main()':
pipes.cpp:64:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(int j=1;j<g[i].size();j++){
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4696 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
4956 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
191 ms |
5456 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
347 ms |
6784 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
576 ms |
10080 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
892 ms |
24788 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1357 ms |
25256 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1820 ms |
38184 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2146 ms |
49932 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2609 ms |
62240 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |