# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
428269 |
2021-06-15T09:21:24 Z |
Peti |
Flood (IOI07_flood) |
C++14 |
|
174 ms |
12784 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){
//cout<<"bejar: "<<g[akt].x<<" "<<g[akt].y<<"\n";
if(akt == s && os != -1){
//cout<<"veg-------------------"<<endl;
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){
//cout<<"el: "<<irany<<" | "<<g[akt].t[irany].first<<" "<<g[akt].t[irany].second<<endl;
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);
}
//cout<<"veg-------------------"<<endl;
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);
//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 |
316 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 |
2 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 |
Incorrect |
20 ms |
3020 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
11128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
10260 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
171 ms |
12340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
174 ms |
12784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |