# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
948294 |
2024-03-18T03:45:40 Z |
vjudge1 |
Pipes (CEOI15_pipes) |
C++17 |
|
780 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
#define Baytoro_Mayrambekov void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
//#define int long long
#define endl '\n'
const int INF=1e18;
void fopn(string name){
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
int binpow(int a,int n){
if(n==0)
return 1;
if(n%2==1)
return binpow(a, n-1)*a;
else{
int b=binpow(a, n/2);
return b*b;
}
}
const int N=20004;
vector<int> ar[N],up(N),tin(N),color(N);
vector<bool> used(N);
int timer,mxcol=0;
map<pair<int,int>,bool> mp;
map<pair<int,int>,int> e_cnt;
void bridge(int x, int p=-1){
used[x]=1;
tin[x]=up[x]=timer++;
for(auto it: ar[x]){
if(it==p) continue;
if(used[it])
up[x]=min(up[x],tin[it]);
else{
bridge(it,x);
up[x]=min(up[x],up[it]);
if(up[it]>tin[x]){
mp[{it,x}]=1;
mp[{x,it}]=1;
}
}
}
}
void dfs(int x, int c){
color[x]=c;
used[x]=1;
for(auto it: ar[x]){
if(!used[it] && (!mp[{x,it}] || e_cnt[{x,it}]!=1))
dfs(it,c);
}
}
int a,b,c,n,m,i,j,k,x,y,cnt=0,sum=0,res=0;
Baytoro_Mayrambekov{
cin>>n>>m;
for(i=0;i<m;i++){
cin>>a>>b;
a--;
b--;
e_cnt[{a,b}]++;
e_cnt[{b,a}]++;
ar[a].pb(b);
ar[b].pb(a);
}
for(i=0;i<n;i++){
if(!used[i])
bridge(i);
}
used.assign(N,0);
int c=0;
for(i=0;i<n;i++){
if(!used[i])
dfs(i,++c);
}
for(int i=0;i<n;i++){
for(auto it: ar[i]){
if(color[i]!=color[it] && i<it){
cout<<i+1<<' '<<it+1<<endl;
}
}
}
}
main(){
ios;
int T=1;
//cin>>T;
while(T--){
solve();
}
}
Compilation message
pipes.cpp:12:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
12 | const int INF=1e18;
| ^~~~
pipes.cpp:88:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
88 | main(){
| ^~~~
pipes.cpp: In function 'void fopn(std::string)':
pipes.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | freopen((name+".in").c_str(),"r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pipes.cpp:15:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | freopen((name+".out").c_str(),"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
10 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
748 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
780 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1948 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |