# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109976 |
2019-05-08T13:44:19 Z |
someone_aa |
Pipes (CEOI15_pipes) |
C++17 |
|
5000 ms |
7260 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);
uparent[y] = x;
usize[x] += usize[y];
}
}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;
u--; v--;
if(two.uroot(u) == two.uroot(v)) continue;
if(one.uroot(u) != one.uroot(v)) {
one.unite(u, v);
g[u].pb(v);
g[v].pb(u);
}
else {
two.unite(u, v);
g[u].pb(v);
g[v].pb(u);
}
}
for(int i=0;i<n;i++) {
if(!visited[i]) {
dfs(i, -1);
}
}
for(auto i:result) {
cout<<i.first+1<<" "<<i.second+1<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2688 KB |
Output is correct |
2 |
Incorrect |
3 ms |
2688 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
3324 KB |
Output is correct |
2 |
Incorrect |
15 ms |
3044 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1624 ms |
3060 KB |
Output is correct |
2 |
Incorrect |
470 ms |
2920 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5079 ms |
3264 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5051 ms |
4044 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5081 ms |
6136 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5059 ms |
6476 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5089 ms |
7244 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5042 ms |
7260 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5038 ms |
7036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |