# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
129815 |
2019-07-13T09:50:46 Z |
khulegub |
Flood (IOI07_flood) |
C++14 |
|
2000 ms |
18148 KB |
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
/*
fix no point with 2 childs
*/
using namespace std;
typedef pair<int, int> pii;
typedef long long i64;
int xac = 0;
int n;
int w;
// bool dbg = 0;
int to[100005][4];
bool path[100005];
vector<pii> p;
vector<pii> wll;
int dfs(int u, int dir, bool f){
if (path[u]) return u;
path[u] = 1;
int arr[4];
arr[0] = (dir + 1) % 4;
arr[1] = dir;
arr[2] = (dir + 3) % 4;
arr[3] = (dir + 2) % 4;
for (int i = 0; i < 4; i++){
int v = to[u][arr[i]];
if (f == 0 && i == 3) continue;
if (v != 0){
int tmp = dfs(v, arr[i], 0);
if (tmp != -1){
to[u][arr[i]] = 0;
to[v][ (arr[i] + 2) % 4 ] = 0;
xac++;
if (tmp != u){
path[u] = 0;
return tmp;
}
}
}
}
path[u] = 0;
return -1;
}
int main(){
// freopen("in.txt", "r", stdin);
cin >> n;
vector<pair<pair<int, int> , int> > p2;
p.resize(n + 1);
p2.resize(n);
for (int i = 1, tx, ty; i <= n; i++){
cin >> tx >> ty;
p[i] = mp(tx, ty);
p2[i - 1] = mp(mp(tx,ty), i);
}
cin >> w;
wll.resize(w + 1);
for (int i = 1, a, b; i <= w; i++){
cin >> a >> b;
int dx = p[b].xx - p[a].xx;
int dy = p[b].yy - p[a].yy;
int dir;
if (dx != 0){ // horizontal
if (dx > 0) dir = 1;
else dir = 3;
}
else{ //vert
if (dy > 0) dir = 0;
else dir = 2;
}
to[a][dir] = b;
to[b][(dir + 2) % 4] = a;
wll[i] = mp(a, dir);
}
sort(p2.begin(), p2.end());
for (int i = 0; i < n; i++){
dfs(p2[i].yy , 0, 1);
}
cout << w - xac << '\n';
for (int i = 1; i <= w; i++){
if ( to[wll[i].xx][wll[i].yy] != 0 ) cout << i << '\n';
// if ( to[wll[i].xx][wll[i].yy] != 0 ) cout << wll[i].xx << ' ' << to[wll[i].xx][wll[i].yy] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
1984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2048 ms |
8264 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
6604 KB |
Output is correct |
2 |
Correct |
310 ms |
8824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
285 ms |
8060 KB |
Output is correct |
2 |
Correct |
319 ms |
8568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
314 ms |
8508 KB |
Output is correct |
2 |
Execution timed out |
2057 ms |
18148 KB |
Time limit exceeded |