# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
451399 |
2021-08-03T07:43:09 Z |
ak2006 |
Pipes (CEOI15_pipes) |
C++14 |
|
1515 ms |
28048 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
const ll mod = 1e9 + 7,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void setIO()
{
fast;
}
int maxN = 1e5 + 5,n,m,TIMER;
vvi adj(2 * maxN);
vb vis(maxN);
vi low(maxN),in(maxN),p1(maxN,-1),p2(maxN,-1);
int Find1(int u)
{
if (p1[u] < 0)return u;
return p1[u] = Find1(p1[u]);
}
int Find2(int u)
{
if (p2[u] < 0)return u;
return p2[u] = Find2(p2[u]);
}
bool Merge1(int u,int v)
{
u = Find1(u),v = Find1(v);
if (u == v)return false;
if (p1[v] > p1[u])swap(u,v);
p1[u] += p1[v];
p1[v] = u;
return true;
}
bool Merge2(int u,int v)
{
u = Find2(u),v = Find2(v);
if (u == v)return false;
if (p2[v] > p2[u])swap(u,v);
p2[u] += p2[v];
p2[v] = u;
return true;
}
void dfs(int u,int p)
{
vis[u] = 1;
in[u] = low[u] = ++TIMER;
for (int v:adj[u]){
if (v == p)continue;
if (vis[v]){
low[u] = min(low[u],in[v]);
continue;
}
dfs(v,u);
low[u] = min(low[u],low[v]);
if (low[v] > in[u])
cout<<u<<" "<<v<<'\n';
}
}
int main()
{
setIO();
cin>>n>>m;
int cnt = 0;
for (int i = 1;i<=m;i++){
int u,v;
cin>>u>>v;
if (Merge1(u,v) or Merge2(u,v))
adj[u].pb(v),adj[v].pb(u),cnt++;
assert(cnt <= 2 * n - 2);
}
for (int i = 1;i<=n;i++)if (!vis[i])dfs(i,-1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6604 KB |
Output is correct |
2 |
Incorrect |
4 ms |
6476 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
7116 KB |
Output is correct |
2 |
Incorrect |
8 ms |
6860 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
10820 KB |
Output is correct |
2 |
Incorrect |
136 ms |
10652 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
235 ms |
12484 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
372 ms |
13628 KB |
Output is correct |
2 |
Correct |
315 ms |
12280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
497 ms |
14648 KB |
Output is correct |
2 |
Runtime error |
477 ms |
28048 KB |
Memory limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
787 ms |
19512 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1124 ms |
21268 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1238 ms |
17692 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1515 ms |
20844 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |