# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
95120 |
2019-01-27T12:49:45 Z |
MrTEK |
Pipes (CEOI15_pipes) |
C++11 |
|
1191 ms |
13152 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
const int N = 1e5 + 5;
int n,m,u,v,t,tin[N],fup[N];
vector <int> ed[N];
bool vis[N];
class dsu { public:
int dad[N];
void init() {
for (int i = 1 ; i <= n ; i++)
dad[i] = i;
}
int find(int x) {
if (x == dad[x])
return x;
return dad[x] = find(dad[x]);
}
bool merge(int x,int y) {
int dx = find(x) , dy = find(y);
if (dx == dy)
return false;
dad[dx] = dy;
return true;
}
}t1,t2;
int dfs(int cur,int par) {
vis[cur] = true;
tin[cur] = fup[cur] = ++t;
int cnt = 0;
for (auto i : ed[cur]) {
if (i == par) {
cnt++;
continue;
}
if (vis[i])
fup[cur] = min(fup[cur],tin[i]);
else{
int temp = dfs(i,cur);
fup[cur] = min(fup[cur],fup[i]);
if (fup[i] > tin[cur] && temp == 1)
cout << cur << " " << i << "\n";
}
}
return cnt;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> m;
t1.init();
t2.init();
for (int i = 1 ; i <= m ; i++) {
cin >> u >> v;
if (t1.merge(u,v) || t2.merge(u,v)) {
ed[u].push_back(v);
ed[v].push_back(u);
}
}
for (int i = 1 ; i <= n ; i++)
if (vis[i] == false)
dfs(i,-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
4 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
3188 KB |
Output is correct |
2 |
Correct |
7 ms |
2940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
3044 KB |
Output is correct |
2 |
Correct |
94 ms |
2944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
3720 KB |
Output is correct |
2 |
Correct |
186 ms |
3324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
5172 KB |
Output is correct |
2 |
Correct |
243 ms |
5036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
416 ms |
10056 KB |
Output is correct |
2 |
Correct |
363 ms |
7268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
630 ms |
11100 KB |
Output is correct |
2 |
Correct |
576 ms |
8732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
818 ms |
13148 KB |
Output is correct |
2 |
Correct |
833 ms |
9084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1010 ms |
13152 KB |
Output is correct |
2 |
Correct |
1044 ms |
9084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1191 ms |
12544 KB |
Output is correct |
2 |
Correct |
1117 ms |
10156 KB |
Output is correct |