# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109107 |
2019-05-04T11:19:27 Z |
MetB |
Flood (IOI07_flood) |
C++14 |
|
2000 ms |
33792 KB |
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>
using namespace std;
const long long INF = 1e9 + 1, MOD = 998244353;
typedef long long ll;
struct point
{
int x, y, ind;
int l[4], e[4];
bool operator < (const point& b) const
{
return (x == b.x ? y < b.y : x < b.x);
}
} a[100000];
struct edge
{
int x, y, ind;
bool operator < (const edge& b) const
{
return ind < b.ind;
}
} b[200000];
int degree[100000], n, w;
set <edge> to_erase, ans;
set <point> s;
map <int, int> g[100000];
void ccw (int x)
{
int f = x;
int pos = 2;
do
{
int new_pos = (pos + 1) % 4;
while (a[f].l[new_pos] == -1)
{
new_pos--;
if (new_pos < 0) new_pos = 3;
}
pos = new_pos;
edge k = b[a[f].e[pos]];
if (to_erase.find (k) == to_erase.end ()) to_erase.insert (k);
else ans.insert (k);
f = a[f].l[pos];
}
while (f != x);
}
int main ()
{
cin >> n;
for (int i = 0; i < n; i++)
{
int x, y;
scanf ("%d%d", &x, &y);
a[i] = {x, y, i, -1, -1, -1, -1, -1, -1, -1, -1};
}
cin >> w;
for (int i = 0; i < w; i++)
{
int x, y;
scanf ("%d%d", &x, &y);
x--;
y--;
b[i] = {x, y, i};
if (x > y) swap (x, y);
g[x][y] = i;
degree[x]++;
degree[y]++;
if (a[x].x == a[y].x)
{
if (a[x].y > a[y].y)
{
a[x].l[2] = y;
a[x].e[2] = i;
a[y].l[0] = x;
a[y].e[0] = i;
}
else
{
a[x].l[0] = y;
a[x].e[0] = i;
a[y].l[2] = x;
a[y].e[2] = i;
}
}
else
{
if (a[x].x > a[y].x)
{
a[x].l[1] = y;
a[x].e[1] = i;
a[y].l[3] = x;
a[y].e[3] = i;
}
else
{
a[x].l[3] = y;
a[x].e[3] = i;
a[y].l[1] = x;
a[y].e[1] = i;
}
}
}
for (int i = 0; i < n; i++)
s.insert (a[i]);
while (!s.empty ())
{
point corner = *s.rbegin ();
//cout << endl;
to_erase.clear ();
ccw (corner.ind);
for (auto e : to_erase)
{
//cout << a[e.x].x << ' ' << a[e.x].y << ' ' << a[e.y].x << ' ' << a[e.y].y << endl;
degree[e.x]--;
degree[e.y]--;
if (a[e.x].x == a[e.y].x)
{
if (a[e.x].y > a[e.y].y)
{
a[e.x].l[2] = -1;
a[e.y].l[0] = -1;
}
else
{
a[e.x].l[0] = -1;
a[e.y].l[2] = -1;
}
}
else
{
if (a[e.x].x > a[e.y].x)
{
a[e.x].l[1] = -1;
a[e.y].l[3] = -1;
}
else
{
a[e.x].l[3] = -1;
a[e.y].l[1] = -1;
}
}
if (degree[e.x] == 0) s.erase (a[e.x]);
if (degree[e.y] == 0) s.erase (a[e.y]);
}
}
cout << ans.size () << endl;
for (edge it : ans)
{
printf ("%d\n", it.ind + 1);
}
}
Compilation message
flood.cpp: In function 'int main()':
flood.cpp:83:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d", &x, &y);
~~~~~~^~~~~~~~~~~~~~~~
flood.cpp:93:9: 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 |
Correct |
8 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
6 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5120 KB |
Output is correct |
2 |
Correct |
8 ms |
5248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2033 ms |
4992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5120 KB |
Output is correct |
2 |
Correct |
7 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
5120 KB |
Output is correct |
2 |
Correct |
9 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2009 ms |
9728 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
157 ms |
23080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
23080 KB |
Output is correct |
2 |
Correct |
523 ms |
31316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
441 ms |
26596 KB |
Output is correct |
2 |
Correct |
436 ms |
31404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
517 ms |
28064 KB |
Output is correct |
2 |
Runtime error |
381 ms |
33792 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |