# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
428284 |
2021-06-15T09:36:58 Z |
Peti |
Flood (IOI07_flood) |
C++14 |
|
156 ms |
18620 KB |
#include <bits/stdc++.h>
using namespace std;
struct pont{
int x, y;
vector<pair<int, int>> t = {{-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}};
bool operator < (const pont &p) const{
if(y != p.y)
return y > p.y;
return x < p.x;
}
};
int index(int x, int f){
x += f;
if(x >= 4) x -= 4;
if(x < 0) x += 4;
return x;
}
vector<pont> g;
vector<int> elek;
void bejar(int os, int akt, int f, int s){
if(akt == s && os != -1){
g[akt].t[index(f, 2)] = make_pair(-1, -1);
return;
}
int irany = index(f, 1);
for(int i = 0; i < 4; i++){
if(g[akt].t[irany].first != -1){
int kov = g[akt].t[irany].first;
elek[g[akt].t[irany].second]++;
g[akt].t[irany] = make_pair(-1, -1);
bejar(akt, kov, irany, s);
if(os != -1)
g[akt].t[index(f, 2)] = make_pair(-1, -1);
return;
}
irany = index(irany, -1);
}
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin>>n;
g.assign(n, pont());
for(int i = 0; i < n; i++)
cin>>g[i].x>>g[i].y;
cin>>m;
elek.assign(m, 0);
for(int i = 0; i < m; i++){
int a, b;
cin>>a>>b;
a--;
b--;
if(g[a].x == g[b].x){
if(g[a].y > g[b].y) swap(a, b);
g[a].t[0] = make_pair(b, i);
g[b].t[2] = make_pair(a, i);
} else{
if(g[a].x > g[b].x) swap(a, b);
g[a].t[1] = make_pair(b, i);
g[b].t[3] = make_pair(a, i);
}
}
vector<int> v(n);
iota(v.begin(), v.end(), 0);
sort(v.begin(), v.end(), [](int a, int b){ return g[a] < g[b]; });
for(int x : v){
bejar(-1, x, 3, x);
bejar(-1, x, 3, x);
}
//cout<<"finished"<<endl;
vector<int> ki;
for(int i = 0; i < m; i++)
if(elek[i] == 2)
ki.push_back(i+1);
cout<<ki.size()<<"\n";
for(int x : ki)
cout<<x<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
9164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
7964 KB |
Output is correct |
2 |
Correct |
154 ms |
12736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
143 ms |
9660 KB |
Output is correct |
2 |
Correct |
156 ms |
12792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
9952 KB |
Output is correct |
2 |
Correct |
143 ms |
18620 KB |
Output is correct |