# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
145236 |
2019-08-19T11:12:51 Z |
letrongdat |
Flood (IOI07_flood) |
C++17 |
|
224 ms |
30568 KB |
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define pr pair < int, int >
#define forn(i, a, b) for(int i=a; i<=b; ++i)
#define repn(i, a, b) for(int i=a; i <b; ++i)
const int N = 1e5 + 10;
vector < pair < pr, int > > v;
multiset < pair < pr, int > > ms;
int n, w;
vector < pr > e[N][5];
bool visit[N];
vector < int > ans;
pr p[N];
istream & operator >> (istream &is, pr &p) {
is >> p.x >> p.y;
return is;
}
int direction(pr &pa, pr &pb) {
if (pb.x == pa.x) {
if (pb.y > pa.y) return 0;
return 2;
}
if (pb.x > pa.x) return 1;
return 3;
}
int go(int u, int dir = 0) {
if (visit[u]) return u;
visit[u] = true;
repn(i, 0, 4) {
int nxt = ( (dir + 1) - i + 4 ) % 4;
if (e[u][nxt].empty()) continue;
auto ed = e[u][nxt].front();
e[u][nxt].clear();
int v = ed.y;
e[v][(nxt + 2) % 4].clear();
int loop = go(v, nxt);
if (!loop) {
ans.pb(ed.x);
continue;
}
if (loop != u) {
visit[u] = false;
return loop;
}
}
visit[u] = false;
return 0;
}
int main() {
ios::sync_with_stdio(0);
cin >> n;
forn(i, 1, n) {
cin >> p[i];
v.pb({p[i], i});
}
cin >> w;
forn(i, 1, w) {
int u, v;
cin >> u >> v;
e[u][direction(p[u], p[v])].pb({i, v});
e[v][direction(p[v], p[u])].pb({i, u});
}
sort(v.begin(), v.end());
for(auto st: v) go(st.y);
cout << ans.size() << '\n';
for(auto id: ans) cout << id << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12024 KB |
Output is correct |
2 |
Correct |
13 ms |
12128 KB |
Output is correct |
3 |
Correct |
13 ms |
12024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
12024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
12024 KB |
Output is correct |
2 |
Correct |
16 ms |
12152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12024 KB |
Output is correct |
2 |
Correct |
13 ms |
12152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12152 KB |
Output is correct |
2 |
Correct |
13 ms |
12152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12152 KB |
Output is correct |
2 |
Correct |
13 ms |
12152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
14708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
22712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
21864 KB |
Output is correct |
2 |
Correct |
207 ms |
27216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
25292 KB |
Output is correct |
2 |
Correct |
224 ms |
27452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
207 ms |
26956 KB |
Output is correct |
2 |
Correct |
213 ms |
30568 KB |
Output is correct |