Submission #70028

# Submission time Handle Problem Language Result Execution time Memory
70028 2018-08-22T09:27:28 Z 3zp popa (BOI18_popa) C++14
0 / 100
27 ms 436 KB
#include<bits/stdc++.h>
#include "popa.h"
using namespace std;
int l[1009], r[1009];
int SOLVE(int le, int ri, int *Left, int *Right){
    if(le > ri) return -1;
    for(int i = le; i <= ri; i++){
        if(l[i] <= le && r[i] >= ri){
            int A = SOLVE(le, i - 1, Left, Right);
            int B = SOLVE(i + 1, ri, Left, Right);
            Left[i] = A;
            Right[i] = B;
            return i;
        }
    }
}
int solve(int N, int* Left, int* Right){
    stack<int> S;
    for(int i = 0; i < N; i++){
        while(S.size() && query(S.top(), i,i,i)){
            S.pop();
        }
        if(!S.size()) l[i] = 0;
        else l[i] = S.top();
        S.push(i);
    }
    while(S.size()) S.pop();
    for(int i = N - 1; i >= 0; i--){
        while(S.size() && query(i ,S.top(),i,i)){
            S.pop();
        }
        if(!S.size()) r[i] = N - 1;
        else r[i] = S.top();
        S.push(i);
    }
    return SOLVE(0, N - 1, Left, Right);

}

Compilation message

popa.cpp: In function 'int SOLVE(int, int, int*, int*)':
popa.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 304 KB not a valid solution
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 436 KB not a valid solution
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 436 KB too many queries
2 Halted 0 ms 0 KB -