// ###
// #---##
// ####-0----##
// ####--------#
// #--------#
// ##-------#
// #-------#
// #-------#
// ##--------#
// #---------# #####
// #-------##-------####### Ya katala
// #------#----------------#
// #------##-----------------#
// #------##------------------#
// #-----#---------------------#
// #-----##---------------------#
// #------##--------------------#
// #-------##-------------------#
// #--------##------------------#
// ############################ #
// || ||
// || ||
// || ||
// || ||
// ####| ####|
#include <bits/stdc++.h>
#include <iostream>
#define for0(i , v) for (int i = 0 ; i < v.size() ; i++)
#define for1(i , n) for (int i = 1 ; i <= n ; i++)
#define AIDS ios_base::sync_with_stdio(0)
#define pb push_back
#define pp pop_back
#define sz(a) a.size()
#define all(x) x.begin() , x.end()
#define F first
#define S second
#define mp make_pair
#define ld long double
#define ll long long
#define pii pair<int, int>
#define in insert
#define vi vector <int>
#define vvi vector <vi>
#define Case "Case " << num << ": "
const int N = 1e6 + 3;
const ll INF = 1e18 + 100;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int dx[] = {0 , 1 , 0 , -1 , 0};
const int dy[] = {0 , 0 , 1 , 0 , -1};
const char dd[] = {' ' , 'D' , 'R' , 'U' , 'L'};
using namespace std;
vector <int> g[10001];
set <pii> q;
bool used[10001];
int tin[10001] , fup[10001] , timer;
void dfs (int v, int p) {
used[v] = 1;
tin[v] = fup[v] = timer++;
for (int to : g[v]) {
if (to == p) continue;
if (used[to])
fup[v] = min (fup[v], tin[to]);
else {
dfs (to, v);
fup[v] = min (fup[v], fup[to]);
if (fup[to] > tin[v]) {
q.in(mp(min(v , to) , max(v , to)));
}
}
}
}
main () {
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
AIDS;
int n , m;
cin >> n >> m;
for (int i = 1 ; i <= m ; i++) {
int l , r;
cin >> l >> r;
g[l].pb(r);
g[r].pb(l);
}
for (int i = 1 ; i <= n ; i++) {
if (!used[i]) {
dfs(i , -1);
}
}
for (auto it : q) {
cout << it.first << " " << it.second << endl;
}
}
Compilation message
pipes.cpp:83:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main () {
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Incorrect |
2 ms |
512 KB |
Wrong number of edges |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1152 KB |
Output is correct |
2 |
Incorrect |
5 ms |
944 KB |
Wrong number of edges |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
148 ms |
8732 KB |
Output is correct |
2 |
Correct |
137 ms |
8056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
265 ms |
12216 KB |
Output is correct |
2 |
Runtime error |
350 ms |
16504 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1072 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |