# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109969 |
2019-05-08T13:24:27 Z |
someone_aa |
Pipes (CEOI15_pipes) |
C++17 |
|
4364 ms |
14812 KB |
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
vector<int>g[maxn];
int n, m;
int tin[maxn], low[maxn];
class dsu {
public:
int uparent[maxn], usize[maxn];
void init() {
for(int i=0;i<=n;i++) {
uparent[i] = i;
usize[i] = 1;
}
}
int uroot(int x) {
while(x != uparent[x]) {
x = uparent[x];
}
return x;
}
bool connected(int x, int y) {
return uroot(x) == uroot(y);
}
void unite(int x, int y) {
x = uroot(x);
y = uroot(y);
if(usize[x] > usize[y]) {
uparent[y] = x;
usize[x] += usize[y];
}
else {
uparent[x] = y;
usize[y] += usize[x];
}
}
}one, two;
int br;
bool visited[maxn];
set<pair<int,int> > result;
void dfs(int node, int p) {
if(visited[node]) return;
tin[node] = br++;
low[node] = tin[node];
visited[node] = true;
for(int i:g[node]) {
if(i == p) continue;
if(visited[i]) {
low[node] = min(low[node], tin[i]);
}
else {
dfs(i, node);
low[node] = min(low[node], low[i]);
if(low[i] > tin[node]) {
result.insert(mp(min(i, node), max(i, node)));
}
}
}
}
int main() {
cin>>n>>m;
int u, v;
one.init();
two.init();
for(int i=0;i<m;i++) {
cin>>u>>v;
if(!one.connected(u, v)) {
one.unite(u, v);
g[u].pb(v);
g[v].pb(u);
}
else {
if(two.connected(u, v)) continue;
two.unite(u, v);
g[u].pb(v);
g[v].pb(u);
}
}
for(int i=1;i<=n;i++) {
if(!visited[i]) {
dfs(i, -1);
}
}
for(auto i:result) {
cout<<i.first<<" "<<i.second<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2688 KB |
Output is correct |
2 |
Incorrect |
4 ms |
2688 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
3200 KB |
Output is correct |
2 |
Incorrect |
11 ms |
3072 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
312 ms |
3100 KB |
Output is correct |
2 |
Incorrect |
302 ms |
2936 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
550 ms |
3916 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
936 ms |
5600 KB |
Output is correct |
2 |
Correct |
808 ms |
5424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1313 ms |
11380 KB |
Output is correct |
2 |
Incorrect |
1097 ms |
7928 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1974 ms |
12460 KB |
Output is correct |
2 |
Incorrect |
1938 ms |
9848 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2690 ms |
14808 KB |
Output is correct |
2 |
Incorrect |
2583 ms |
9956 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3342 ms |
14812 KB |
Output is correct |
2 |
Incorrect |
3313 ms |
9952 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4364 ms |
14260 KB |
Output is correct |
2 |
Correct |
3914 ms |
11740 KB |
Output is correct |