# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
152708 |
2019-09-09T08:52:28 Z |
toloraia |
Pipes (CEOI15_pipes) |
C++17 |
|
2155 ms |
65540 KB |
#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], gg[N];
vector < ll > G[N];
int x, y;
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 (i && g[k][i - 1] == to)
continue;
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]);
}
}
}
vector < ll > 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 (int i = 1; i <= m; i++){
scanf ("%d %d", &x, &y);
if (x > y)
swap (x, y);
g[x].pb (y);
}
int t, num;
ll X, j;
for (int i = 1; i <= n; i++){
num = (int)g[i].size();
V.clear();
for (int j = 0; j < num; j++){
if (j && g[i][j] == g[i][j - 1])
continue;
if (j + 1 < num && g[i][j] == g[i][j + 1])
V.pb (g[i][j] + n);
else
V.pb (g[i][j]);
}
for (int to : g[i]){
gg[to].pb (i);
}
g[i].clear();
num = (int)V.size();
for (j = 0; j < num; j += 3){
X = 0;
for (t = j; t < j + 3 && t < num; t++){
X = X * K + V[t];
}
G[i].pb (X);
}
}
for (int i = 1; i <= n; i++){
g[i] = gg[i];
gg[i].clear();
num = (int)g[i].size();
V.clear();
for (int j = 0; j < num; j++){
if (j && g[i][j] == g[i][j - 1])
continue;
if (j + 1 < num && g[i][j] == g[i][j + 1])
V.pb (g[i][j] + n);
else
V.pb (g[i][j]);
}
g[i].clear();
num = (int)V.size();
for (j = 0; j < num; j += 3){
X = 0;
for (t = j; t < j + 3 && t < num; t++){
X = X * K + V[t];
}
G[i].pb (X);
}
}
for (int i = 1; i <= n; i++)
if (in[i] == 0)
dfs (i, 0);
return 0;
}
Compilation message
pipes.cpp:68:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
pipes.cpp: In function 'int main()':
pipes.cpp:75:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d %d", &x, &y);
~~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
7416 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
8440 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
242 ms |
29276 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
457 ms |
46680 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
817 ms |
64064 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1080 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1600 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2000 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2151 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2155 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |