#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 = n-1;
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.top(),j,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 f(int, int)':
popa.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
16 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
208 KB |
Output is correct |
2 |
Correct |
11 ms |
208 KB |
Output is correct |
3 |
Correct |
8 ms |
208 KB |
Output is correct |
4 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
424 KB |
Output is correct |
2 |
Correct |
86 ms |
332 KB |
Output is correct |
3 |
Correct |
55 ms |
448 KB |
Output is correct |
4 |
Correct |
86 ms |
300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
332 KB |
Output is correct |
2 |
Correct |
120 ms |
328 KB |
Output is correct |
3 |
Correct |
70 ms |
328 KB |
Output is correct |
4 |
Correct |
122 ms |
304 KB |
Output is correct |