# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
118712 |
2019-06-19T13:31:24 Z |
nvmdava |
Flood (IOI07_flood) |
C++17 |
|
326 ms |
16644 KB |
#include <bits/stdc++.h>
#define ss second
#define ff first
using namespace std;
vector<int> pr[4] = {{3, 0, 1, 2}, {0, 1, 2, 3}, {1, 2, 3, 0}, {2, 3, 0, 1}};
int x[100005], y[100005];
pair<int, int> wall[200005];
vector<int> dot;
int to[4][100005];
set<int> in;
set<int> ans;
int last;
void remove(int id){
int v = wall[id].ff, u = wall[id].ss;
for(int i = 0; i < 4; i++){
if(to[i][v] == id) to[i][v] = -1;
if(to[i][u] == id) to[i][u] = -1;
}
}
int change(int& v){
for(int x : pr[last]){
if(to[x][v] != -1){
int e = to[x][v];
if(in.count(e))
ans.insert(e);
else in.insert(e);
v = wall[e].ff + wall[e].ss - v;
last = x;
break;
}
}
return v;
}
int main(){
memset(to, -1, sizeof to);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i = 0; i < n; i++){
cin>>x[i]>>y[i];
dot.push_back(i);
dot.push_back(i);
}
sort(dot.begin(), dot.end(), [](const int& lhs,const int& rhs){
if(x[lhs] != x[rhs]) return x[lhs] < x[rhs];
return y[lhs] < y[rhs];
});
int w;
cin>>w;
for(int i = 0; i < w; i++){
int v, u;
cin>>v>>u;
v--;u--;
wall[i].ff = v;
wall[i].ss = u;
if(x[v] == x[u]){
if(y[v] < y[u])
swap(v, u);
to[0][u] = i;
to[2][v] = i;
} else {
if(x[v] < x[u])
swap(v, u);
to[1][u] = i;
to[3][v] = i;
}
}
for(int a : dot){
if(to[0][a] + to[1][a] + to[2][a] + to[3][a] == -4) continue;
last = 1;
in.clear();
int v = a;
while(change(v) != a);
for(int x : in) remove(x);
}
cout<<ans.size()<<'\n';
for(int x : ans)
cout<<x + 1<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1920 KB |
Output is correct |
2 |
Correct |
3 ms |
1920 KB |
Output is correct |
3 |
Correct |
3 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1920 KB |
Output is correct |
2 |
Correct |
4 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1920 KB |
Output is correct |
2 |
Correct |
3 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1920 KB |
Output is correct |
2 |
Correct |
4 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1920 KB |
Output is correct |
2 |
Correct |
4 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
6156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
4340 KB |
Output is correct |
2 |
Correct |
196 ms |
10256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
7584 KB |
Output is correct |
2 |
Correct |
169 ms |
10952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
7636 KB |
Output is correct |
2 |
Correct |
326 ms |
16644 KB |
Output is correct |