# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
668752 |
2022-12-04T21:30:02 Z |
KiaRez |
Pipes (CEOI15_pipes) |
C++14 |
|
937 ms |
16056 KB |
/*
IN THE NAME OF GOD
...........................................................................................................................
...........................................................................................................................
.......@..........@....@@@@@@@@@............@..............@@@@@@@@@@........@@@@@@@@@@@.......@@@@@@@@@@@@@@@@@...........
.......@........@..........@...............@.@.............@........@........@................................@............
.......@......@............@..............@...@............@........@........@..............................@..............
.......@....@..............@.............@.....@...........@........@........@............................@................
.......@..@................@............@.......@..........@@@@@@@@@@........@..........................@..................
.......@.@.................@...........@@@@@@@@@@@.........@...@.............@@@@@@@@@@@..............@....................
.......@....@..............@..........@...........@........@....@............@......................@......................
.......@.......@...........@.........@.............@.......@.....@...........@....................@........................
.......@.........@.........@........@...............@......@......@..........@..................@..........................
.......@...........@...@@@@@@@@@...@.................@.....@.......@.........@@@@@@@@@@@@......@@@@@@@@@@@@@@@.............
...........................................................................................................................
...........................................................................................................................
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef pair<pii, int> piii;
typedef pair<ll, pll> lpll;
typedef pair<pll, ll> plll;
typedef pair<pii, pii> piipii;
typedef pair<pll, pll> pllpll;
typedef long double ld;
#define SP ' '
#define endl '\n'
#define F first
#define S second
#define Mp make_pair
#define pb push_back
#define pf push_front
#define DASH "---------"
#define UNDERLINE "_________"
#define all(x) (x).begin(),(x).end()
#define FORD(i, s, e) for(int i=s; i>=e; --i)
#define FOR(i, s, e) for(int i=s; i<=e; ++i)
#define kill(x) cout << x << '\n', exit(0);
#define set_dec(x) cout << fixed << setprecision(x);
#define fuck(x) cout << #x << " : " << x << endl
#define ios ios_base::sync_with_stdio(false), cin.tie(0)
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
const int N = 1e5+10;
const ll MOD = 1e9+7;
ll getmod(ll a, ll mod=MOD) {return (a+mod)%mod;}
ll max(ll a, ll b) {return (a>b ? a : b);}
ll min(ll a, ll b) {return (a<b ? a : b);}
ll abso(ll a) {return (a<0?-a:a);}
int n, par[N][2], m, low[N], lay[N], ind2;
bool mark[N];
vector<pii> adj[N];
int getPar(int v, int ind) {int tmpv=v; while(par[v][ind]!=0) {v=par[v][ind];} while(par[tmpv][ind]!=0) {int fck=tmpv; tmpv=par[tmpv][ind]; par[fck][ind]=v;} return v;}
void update(int v, int u, int ind) {v=getPar(v, ind), u=getPar(u, ind);if (v==u){return;}par[v][ind]=u;}
void dfs(int v, int index){
mark[v]=1, lay[v]=lay[par[v][0]]+1;
for(auto it : adj[v]) {
if (!mark[it.F]) {par[it.F][0]=v; dfs(it.F, it.S); low[v]=min(low[v], low[it.F]);}
else if (mark[it.F] && it.S!=index) {low[v]=min(low[v], lay[it.F]);}
}
if (low[v] > lay[par[v][0]] && par[v][0]!=0) {cout << min(v, par[v][0]) << ' ' << max(v, par[v][0]) << endl;}
}
int main () {
ios;
cin>>n>>m; fill(low, low+n+5, 1e9);
FOR(i, 1, m){
int v, u;cin>>v>>u;
if (getPar(v, 0) != getPar(u, 0)) {update(v, u, 0); adj[v].pb({u, ++ind2}); adj[u].pb({v, ind2});}
else if (getPar(v, 1) != getPar(u, 1)) {update(v, u, 1); adj[v].pb({u, ++ind2}); adj[u].pb({v, ind2});}
}
fill(par[0], par[0]+n+5, 0);
FOR(i, 1, n) {if (!mark[i]) {dfs(i, 0);}}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
3284 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
3064 KB |
Output is correct |
2 |
Correct |
83 ms |
3020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
3912 KB |
Output is correct |
2 |
Correct |
203 ms |
3376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
233 ms |
5788 KB |
Output is correct |
2 |
Correct |
190 ms |
5224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
340 ms |
12052 KB |
Output is correct |
2 |
Correct |
334 ms |
8596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
492 ms |
13460 KB |
Output is correct |
2 |
Correct |
448 ms |
9840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
687 ms |
15984 KB |
Output is correct |
2 |
Correct |
629 ms |
11252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
789 ms |
16056 KB |
Output is correct |
2 |
Correct |
762 ms |
11088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
937 ms |
15324 KB |
Output is correct |
2 |
Correct |
899 ms |
11560 KB |
Output is correct |