# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
152711 |
2019-09-09T09:05:25 Z |
toloraia |
Pipes (CEOI15_pipes) |
C++17 |
|
5000 ms |
63052 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];
vector < int > g[N];
ll A[N];
int B[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 (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 < int > V;
int t, num;
ll X;
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 * 2 + 1;
for (i = 1; i <= m; i++){
cin >> x >> y;
if (x > y)
swap (x, y);
g[x].pb (y);
}
for (i = 1; i <= n; i++){
num = (int)g[i].size();
V.clear();
for (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] = V;
}
for (i = 1; i <= n; i++){
for (j = 0; j < g[i].size(); j++){
to = g[i][j];
y = to;
x = i;
if (y > n)
x = i + n, y -= n;
A[i] = A[i] * K + to;
B[i]++;
if (B[i] == 3){
B[i] = 0;
G[i].pb (A[i]);
A[i] = 0;
}
A[y] = A[y] * K + x;
B[y]++;
if (B[y] == 3){
B[y] = 0;
G[y].pb (A[y]);
A[y] = 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
pipes.cpp:74:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
pipes.cpp: In function 'int main()':
pipes.cpp:100:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 0; j < g[i].size(); j++){
~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5112 KB |
Output is correct |
2 |
Incorrect |
7 ms |
5112 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
5880 KB |
Output is correct |
2 |
Incorrect |
19 ms |
5496 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
567 ms |
13748 KB |
Output is correct |
2 |
Correct |
559 ms |
13028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1109 ms |
23516 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 |
1841 ms |
31220 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 |
2494 ms |
44288 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 |
3964 ms |
60320 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 |
Execution timed out |
5061 ms |
63052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5074 ms |
36444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5072 ms |
51820 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |