Submission #152715

#TimeUsernameProblemLanguageResultExecution timeMemory
152715toloraiaPipes (CEOI15_pipes)C++17
30 / 100
5044 ms65536 KiB
#include <bits/stdc++.h> #define F first #define S second #define mp make_pair #define pb push_back #define ll long long #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; ll K; vector < ll > G[N]; ll A[N]; int B[N]; int T; int in[N], up[N]; void dfs (int k, int p){ in[k] = ++T; up[k] = in[k]; int to, i, toto; int num = (int)G[k].size(); ll X; for (i = 0; i < num; i++){ X = G[k][i]; while (X){ toto = X % K; X /= K; to = toto; if (to > n) to -= n; if (to == p) continue; if (in[to]){ up[k] = min (up[k], in[to]); continue; } dfs (to, k); if (up[to] > in[k] && to == toto){ cout << k << " " << to << endl; } up[k] = min (up[k], up[to]); } } } int t, num; ll X; int j; int i, to; pair < int, int > P[M]; int u, v; main() { //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout); //ios_base::sync_with_stdio(false); cin >> n >> m; K = n * 2 + 1; for (i = 1; i <= m; i++){ cin >> P[i].F >> P[i].S; } sort (P + 1, P + m + 1); for (int i = 1; i <= m; i++){ if (P[i] == P[i - 1]) continue; u = P[i].F; v = P[i].S; A[u] = A[u] * K + v; B[u]++; A[v] = A[v] * K + u; B[v]++; if (P[i + 1] == P[i]){ A[u] += n; A[v] += n; } if (B[u] == 4){ G[u].pb (A[u]); A[u] = 0; B[u] = 0; } if (B[v] == 4){ G[v].pb (A[v]); A[v] = 0; B[v] = 0; } } for (i = 1; i <= n; i++) if (A[i]) G[i].pb (A[i]); for (i = 1; i <= n; i++) if (in[i] == 0) dfs (i, 0); return 0; }

Compilation message (stderr)

pipes.cpp:74:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...