답안 #578669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
578669 2022-06-17T14:11:06 Z FatihSolak popa (BOI18_popa) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "popa.h"
#define N 1005
using namespace std;
int L[N],R[N];
int prv[N];
int f(int l,int r){
    if(l > r)return -1;
    for(int i = r;i>=l;i--){
        if(prv[i] < l){
            L[i] = f(l,i-1);
            R[i] = f(i+1,r);
            return i;
        }
    }
}
int solve(int n, int* Left, int* Right){
    for(int i = 0;i<n;i++){
        L[i] = R[i] = -1;
        prv[i] = -1;
    }
    for(int i = 0;i<n;i++){
        int r = i;
        while(r + 1 != n && query(i,r+1,i,i))
            r++;
        stack<int> st;
        for(int j = i;j<=r;j++){
            while(st.size() && query(st.back(),st.back(),j,j)){
                st.pop();
            }
            if(st.size())
                prv[j] = st.top();
            st.push(j);
        }
        i = r;
    }
    int ret = f(0,n-1);
    for(int i = 0;i<n;i++){
        Left[i] = L[i];
        Right[i] = R[i];
    }
    return ret;
}

Compilation message

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:28:41: error: 'class std::stack<int>' has no member named 'back'
   28 |             while(st.size() && query(st.back(),st.back(),j,j)){
      |                                         ^~~~
popa.cpp:28:51: error: 'class std::stack<int>' has no member named 'back'
   28 |             while(st.size() && query(st.back(),st.back(),j,j)){
      |                                                   ^~~~
popa.cpp: In function 'int f(int, int)':
popa.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
   16 | }
      | ^