# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
669508 |
2022-12-06T15:25:17 Z |
arashMLG |
Pipes (CEOI15_pipes) |
C++17 |
|
963 ms |
38000 KB |
// Link: https://oj.uz/problem/view/CEOI15_pipes
// Status: NOT SOLVED
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;
const int N = 1e6 + 2;
const ll mod = 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define F first
#define S second
#define pb push_back
#define ms(x,y) memset((x) , (y) , sizeof (x))
#define done return cout<<endl , 0;
#define kill(x) cout<<x; exit(0);
#define isIn(x,s,e) ((x) >= (s) && (x) <= e)
//#define int ll
ll pw(ll a, ll b, ll md = mod){ll res = 1; while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}
int n,m,a,b;
int par[N][2],h[N],p[N];
int dp[N];
vector<int> G[N];
int getPar(int v,int x) {
return par[v][x] == 0 ? v : par[v][x] = getPar(par[v][x], x);
}
bool merge(int v, int u , int x){
v = getPar(v,x),u = getPar(u,x); if(u == v) return false; par[v][x] = u; return true;
}
void dfs(int v) {
bool ok = false;
for(auto u : G[v]) {
//cerr<<"YE";
if(h[u] == -1) {
h[u] = h[v] + 1;
p[u] = v;
dfs(u);
dp[v] += dp[u];
} else if(h[u] < h[v] && (ok || u != p[v])) {
dp[v] ++;
dp[u] --;
} else if(u == p[v]) {
ok = true;
}
}
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
ms(h,-1);
cin>>n>>m;
for(int i = 1; i <= m; i ++) {
cin>>a>>b;
if(merge(a,b,0)) {
G[a].pb(b); G[b].pb(a);
} else if(merge(a,b,1)) {
G[a].pb(b); G[b].pb(a);
}
}
for(int i = 1; i <= n ; i++) {
if(h[i] == -1) {
h[i] = 0; p[i] = 0;
dfs(i);
}
}
for(int i = 1; i <= n; i ++) {
if(dp[i] == 0 && p[i] != 0) {
cout<<i << ' ' << p[i] <<'\n';
}
}
done;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
27708 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
28116 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
93 ms |
28028 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
165 ms |
28712 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
249 ms |
30148 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
326 ms |
34992 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
500 ms |
36120 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
659 ms |
38000 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
819 ms |
37960 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
963 ms |
37500 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |