# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
367100 |
2021-02-16T09:45:46 Z |
duchung |
Pipes (CEOI15_pipes) |
C++17 |
|
2617 ms |
65540 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n , m;
vector<int> edge[N];
int low[N] , tin[N];
bool visited[N];
int timer = 0;
void dfs(int u , int p)
{
low[u] = tin[u] = ++timer;
visited[u] = true;
for (int i = 0 ; i < edge[u].size() ; ++i)
{
int v = edge[u][i];
if (p == v) continue;
if (i + 1 < edge[u].size() && edge[u][i + 1] == v) continue;
if (visited[v])
{
low[u] = min(low[u] , tin[v]);
}
else
{
dfs(v , u);
if (low[v] > tin[u])
{
cout << u << " " << v << "\n";
}
low[u] = min(low[u] , low[v]);
}
}
}
int main()
{
// freopen(".inp","r",stdin);
// freopen(".out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
while(m--)
{
int u , v;
cin >> u >> v;
edge[u].push_back(v);
edge[v].push_back(u);
}
for (int i = 1 ; i <= n ; ++i) sort(edge[i].begin() , edge[i].end());
for (int i = 1 ; i <= n ; ++i) tin[i] = low[i] = -1 , visited[i] = false;
for (int i = 1 ; i <= n ; ++i)
{
if (!visited[i])
{
dfs(i , -1);
}
}
}
Compilation message
pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:18:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for (int i = 0 ; i < edge[u].size() ; ++i)
| ~~^~~~~~~~~~~~~~~~
pipes.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | if (i + 1 < edge[u].size() && edge[u][i + 1] == v) continue;
| ~~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2668 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2668 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
3180 KB |
Output is correct |
2 |
Incorrect |
6 ms |
3052 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
10988 KB |
Output is correct |
2 |
Correct |
184 ms |
10220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
320 ms |
14408 KB |
Output is correct |
2 |
Runtime error |
386 ms |
18796 KB |
Memory limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
635 ms |
25708 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
974 ms |
31520 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1571 ms |
53420 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2017 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2617 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2430 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |