#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll long long
//#define ll __int128
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
/*
#pragma comment(linker, "/STACK: 20000000005")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
using namespace std;
const int N = 1e5 + 5, M = 6e6 + 5;
int n, m;
int K;
vector < int > g[N];
int A[N], AA[N];
int B[N], BB[N];
int x, y;
int T;
int in[N], up[N];
int nn[N], mi[N], sz[N];
int pr[N];
void dfs (int k){
in[k] = ++T;
up[k] = in[k];
int to, i, toto;
int X;
bool ok;
for (i = 0; i < nn[k]; i++){
X = g[k][i];
ok = 0;
if (X % 2 == 0)
ok = 1;
X /= 2;
while (X){
toto = X % K;
X /= K;
to = toto;
if (to > n)
to -= n;
if (to == pr[k])
continue;
if (in[to]){
up[k] = min (up[k], in[to]);
continue;
}
pr[to] = k;
dfs (to, k);
if (up[to] > in[k] && ok == 1){
cout << k << " " << to << endl;
}
up[k] = min (up[k], up[to]);
}
}
}
void dam (int k, int x){
if (nn[k] >= sz[k]){
g[k].pb (x);
nn[k]++;
return;
}
g[k][nn[k]++] = x;
}
int p;
bool ok;
void midi (int k){
if (mi[k] >= sz[k])
return;
p = g[k][mi[k]];
ok = 0;
if (mi[k] < sz[k] - 1 && g[k][mi[k] + 1] == p)
ok = 1;
while (mi[k] < sz[k] - 1 && g[k][mi[k] + 1] == p)
mi[k]++;
mi[k]++;
if (ok){
AA[k] = AA[k] * K + p;
BB[k]++;
AA[p] = AA[p] * K + k;
BB[p]++;
if (BB[k] == 2){
dam (k, AA[k] * 2 + 1);
BB[k] = 0;
AA[k] = 0;
}
if (BB[p] == 2){
dam (p, AA[p] * 2 + 1);
BB[p] = 0;
AA[p] = 0;
}
midi (p);
return;
}
A[k] = A[k] * K + p;
B[k]++;
A[p] = A[p] * K + k;
B[p]++;
if (B[k] == 2){
dam (k, A[k] * 2);
B[k] = 0;
A[k] = 0;
}
if (B[p] == 2){
dam (p, A[p] * 2);
B[p] = 0;
A[p] = 0;
}
midi (p);
}
int t, num;
int j;
int i, to;
main()
{
//freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
//ios_base::sync_with_stdio(false);
cin >> n >> m;
K = n + 1;
for (i = 1; i <= m; i++){
cin >> x >> y;
if (x > y)
swap (x, y);
g[x].pb (y);
sz[x]++;
}
for (i = 1; i <= n; i++){
sort (g[i].begin(), g[i].end());
}
for (int i = 1; i <= n; i++){
while (mi[i] < sz[i])
midi (i);
}
for (i = 1; i <= n; i++)
if (A[i])
dam (i, A[i] * 2);
for (i = 1; i <= n; i++)
if (AA[i])
dam (i, AA[i] * 2 + 1);
for (i = 1; i <= n; i++)
if (in[i] == 0)
dfs (i);
return 0;
}
Compilation message
pipes.cpp: In function 'void dfs(int)':
pipes.cpp:66:23: error: too many arguments to function 'void dfs(int)'
dfs (to, k);
^
pipes.cpp:41:6: note: declared here
void dfs (int k){
^~~
pipes.cpp: At global scope:
pipes.cpp:138:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^