# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
867532 |
2023-10-28T15:30:00 Z |
pizzamoeger |
popa (BOI18_popa) |
C++14 |
|
1 ms |
344 KB |
#include <bits/stdc++.h>
#include "popa.h"
#define ll long long
using namespace std;
int solve(int N, int* Left, int* Right) {
vector<int> parent (N, -1);
for (int i = 0; i < N; i++) {
Left[i] = -1;
Right[i] = -1;
}
int rl = 0;
for (int i = 1; i < N; i++) {
int v = rl;
while(parent[v] != -1 && query(i, i, i, v)) {
v = parent[v];
assert(v != -1);
}
if (parent[v] == -1) {
assert(v != -1);
if (query(i, i, i, v)) {
parent[v] = i;
Left[i] = v;
rl = i;
} else {
parent[i] = v;
Left[i] = Right[v];
Right[v] = i;
rl = i;
}
} else {
parent[i] = v;
Left[i] = Right[v];
Right[v] = i;
rl = i;
}
}
int root = rl;
while (parent[root] != -1) root = parent[root];
return root;
}
/*signed main() {
const int N = 6;
int* Left = new int[N];
int* Right = new int[N];
int ret = solve(N, Left, Right);
cerr << ret;
for (int i = 0; i < N; i++) {
cout << Left[i] << " " << Right[i] << "\n";
}
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
invalid argument |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
invalid argument |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
invalid argument |
2 |
Halted |
0 ms |
0 KB |
- |