#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
vector<int> parent;
int cntr;
int calc(int v, int p) {
while (v != p) {
cntr = max(cntr, v);
if (query(v, v + 1, p, p)) {
parent[v] = p;
calc(v + 1, v);
}
else {
if (query(v, v + 1, v + 1, v + 1))
parent[v] = v + 1;
else {
calc(v + 1, v);
parent[v] = cntr + 1;
}
}
v = parent[v];
}
}
int solve(int N, int* L, int* R) {
L = new int[N], R = new int[N];
cntr = 0;
parent.assign(N, -1);
calc(0, N);
for (int i = 0; i < N; i++)
L[i] = R[i] = -1;
int r = -1;
for (int i = 0; i < N; i++) {
if (parent[i] == -1)
r = i;
else {
if (i < parent[i])
L[parent[i]] = i;
else
R[parent[i]] = i;
}
}
return r;
}
컴파일 시 표준 에러 (stderr) 메시지
popa.cpp: In function 'int calc(int, int)':
popa.cpp:24:1: warning: no return statement in function returning non-void [-Wreturn-type]
24 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |