제출 #1144522

#제출 시각아이디문제언어결과실행 시간메모리
1144522not_amirpopa (BOI18_popa)C++20
0 / 100
0 ms408 KiB
#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;
            if (p != v + 1)
                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:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
   25 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...