# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
451362 |
2021-08-03T07:31:32 Z |
prvocislo |
Flood (IOI07_flood) |
C++17 |
|
292 ms |
31152 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
typedef long long ll;
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n;
vector<int> x(n), y(n);
for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
cin >> m;
vector<int> a(m), b(m);
vector<vector<bool> > vis1(m, vector<bool>(2, false));
vector<bool> vis2(m, false);
vector<vector<int> > g(n, vector<int>(4, -1));
set<pair<pair<int, int>, int>> pq;
for (int i = 0; i < m; i++)
{
cin >> a[i] >> b[i]; a[i]--, b[i]--;
if (x[b[i]] < x[a[i]] || y[b[i]] < y[a[i]]) swap(a[i], b[i]);
if (y[a[i]] == y[b[i]])
{
g[a[i]][0] = i;
g[b[i]][2] = i;
}
if (x[a[i]] == x[b[i]])
{
g[a[i]][3] = i;
g[b[i]][1] = i;
}
pq.insert({ {-x[b[i]], y[b[i]]}, i });
}
while (!pq.empty())
{
int i = pq.begin()->second;
pq.erase(pq.begin());
if (vis2[i]) continue;
//cout << "\n";
int u = a[i], d = find(g[b[i]].begin(), g[b[i]].end(), i) - g[b[i]].begin();
vector<int> nw;
while (true)
{
int e = -1, d2 = -1;
for (int i = 3; i < 7; i++)
{
e = g[u][(d + i) % 4];
if (e != -1 && !vis2[e])
{
d2 = (d + i) % 4;
break;
}
}
bool flag = a[e] == u;
if (vis1[e][flag]) break;
vis1[e][flag] = true;
nw.push_back(e);
u = u ^ a[e] ^ b[e], d = d2;
//cout << e << "\n";
}
for (int e : nw) vis2[e] = true;
}
vector<int> ans;
for (int i = 0; i < m; i++) if (vis1[i][0] && vis1[i][1])
ans.push_back(i);
cout << ans.size() << "\n";
for (int i : ans) cout << i + 1 << "\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 |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 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 |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 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 |
460 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 |
26 ms |
5452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
19300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
20920 KB |
Output is correct |
2 |
Correct |
290 ms |
30380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
219 ms |
26716 KB |
Output is correct |
2 |
Correct |
292 ms |
31152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
29956 KB |
Output is correct |
2 |
Correct |
235 ms |
24176 KB |
Output is correct |