Submission #92913

#TimeUsernameProblemLanguageResultExecution timeMemory
92913Pajarajapopa (BOI18_popa)C++17
100 / 100
88 ms496 KiB
#include <bits/stdc++.h> #include "popa.h" #define MAXN 1007 using namespace std; int ls[MAXN],rs[MAXN],dml[MAXN],dmr[MAXN]; int rek(int lt,int rt) { if(lt>rt) return -1; int l=lt; while(l<=rt && (dml[l]>lt || dmr[l]<rt)) l++; ls[l]=rek(lt,l-1); rs[l]=rek(l+1,rt); return l; } int solve(int N,int* Left,int* Right) { stack<int> st; for(int i=0;i<N;i++) { while(!st.empty()) {if(!query(st.top(),st.top(),st.top(),i)) {dmr[st.top()]=i-1; st.pop();} else break;} if(!st.empty()) dml[i]=st.top()+1; else dml[i]=0; st.push(i); } while(!st.empty()) {dmr[st.top()]=N-1; st.pop();} int a=rek(0,N-1); for(int i=0;i<N;i++) Left[i]=ls[i]; for(int i=0;i<N;i++) Right[i]=rs[i]; return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...