# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
395574 |
2021-04-28T15:45:11 Z |
Berted |
Flood (IOI07_flood) |
C++14 |
|
89 ms |
9864 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#define pii pair<int, int>
#define ppi pair<pii, int>
#define fst first
#define snd second
using namespace std;
const int INF = 1e9;
int N, M; ppi A[100001]; pii C[100001];
pii adj[100001][4];
vector<int> vis;
int H[100001];
bool rem[200001], ans[200001];
int DFS(int u, int pv)
{
int ret = H[u] + 1;
vis.push_back(u);
//cerr << "D: " << u << " " << C[u].fst << " " << C[u].snd << " " << pv << "\n";
for (int k = -1; k < 2; k++)
{
int nx = adj[u][(pv + 4 + k) % 4].fst, id = adj[u][(pv + 4 + k) % 4].snd;
if (nx == -1 || rem[id]) continue;
if (H[nx] < H[u]) {ret = H[nx];}
else {H[nx] = H[u] + 1; ret = DFS(nx, (pv + 4 + k) % 4);}
rem[adj[u][(pv + 4 + k) % 4].snd] = 1;
if (ret <= H[u]) {break;}
else {ans[adj[u][(pv + 4 + k) % 4].snd] = 1;}
}
return ret;
}
int main()
{
ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> N;
for (int i = 0; i < N; i++)
{
cin >> A[i].fst.fst >> A[i].fst.snd; A[i].snd = i; H[i] = INF;
C[i] = A[i].fst;
for (int j = 0; j < 4; j++) adj[i][j] = {-1, -1};
}
cin >> M;
for (int i = 0; i < M; i++)
{
int u, v; cin >> u >> v; u--; v--;
if (A[u].fst.fst == A[v].fst.fst)
{
if (A[u].fst.snd < A[v].fst.snd) {adj[u][0] = {v, i}; adj[v][2] = {u, i};}
else {adj[u][2] = {v, i}; adj[v][0] = {u, i};}
}
else
{
if (A[u].fst.fst < A[v].fst.fst) {adj[u][1] = {v, i}; adj[v][3] = {u, i};}
else {adj[u][3] = {v, i}; adj[v][1] = {u, i};}
}
}
sort(A, A + N);
for (int i = 0; i < N; i++)
{
//cerr << "START: " << A[i].fst.fst << " " << A[i].fst.snd << " " << A[i].snd << "\n";
H[A[i].snd] = 0; DFS(A[i].snd, 0);
for (const int &x : vis) H[x] = INF;
vis.clear();
}
vector<int> ret;
for (int i = 0; i < M; i++)
if (ans[i]) ret.push_back(i + 1);
cout << ret.size() << "\n";
for (const int &x : ret) cout << x << "\n";
}
# |
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 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
9168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
7564 KB |
Output is correct |
2 |
Incorrect |
85 ms |
9816 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
77 ms |
9408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
89 ms |
9864 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |