Submission #152690

#TimeUsernameProblemLanguageResultExecution timeMemory
152690toloraiaPipes (CEOI15_pipes)C++14
0 / 100
7 ms2808 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; int n, m; int nn, u[N], v[N]; vector < int > g[N]; int T; int in[N], up[N]; int x, y; map < pair < int, int >, int > M; void dfs (int k, int p){ in[k] = ++T; up[k] = in[k]; for (int to : g[k]){ if (to == p) continue; if (in[to]){ up[k] = min (up[k], in[to]); continue; } dfs (to, k); if (up[to] > in[k]){ x = min (k, to); y = max (k, to); if (M[{x, y}] == 1){ nn++; u[nn] = k; v[nn] = to; } } up[k] = min (up[k], up[to]); } } main() { freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout); ios_base::sync_with_stdio(false); cin >> n >> m; for (int i = 1; i <= m; i++){ cin >> x >> y; if (x > y) swap (x, y); ++M[{x, y}]; if (M[{x, y}] > 1) continue; g[x].pb (y); g[y].pb (x); } for (int i = 1; i <= n; i++) if (in[i] == 0) dfs (i, 0); for (int i = 1; i <= nn; i++) cout << u[i] << " " << v[i] << endl; return 0; }

Compilation message (stderr)

pipes.cpp:17:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
pipes.cpp:18:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
pipes.cpp:60:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
pipes.cpp: In function 'int main()':
pipes.cpp:62:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
pipes.cpp:62:43: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...