Submission #73659

#TimeUsernameProblemLanguageResultExecution timeMemory
73659yusufakepopa (BOI18_popa)C++11
100 / 100
142 ms704 KiB
#include<bits/stdc++.h> using namespace std; #include "popa.h" #define _ int v, int tl, int tr, int l, int r #define tm (tl+tr >> 1) #define sol v+v,tl,tm,l,r #define sag v+v+1,tm+1,tr,l,r #define pb push_back #define mp make_pair #define st first #define nd second #define pp pair<int,int> const int mod = 1e9 + 7; const int N = 1e3 + 3; int L[N],R[N]; int f(int l, int r, int *lef, int *rig){ if(l > r) return -1; int i; for(i=l;i<=r;i++) if(L[i] < l && R[i] > r) break; lef[i] = f(l,i-1,lef,rig); rig[i] = f(i+1,r,lef,rig); return i; } stack < int > S; int solve(int n, int *lef, int *rig){ int i; for(i=0;i<n;i++){ for(; S.size() && query(S.top(),i,i,i) ;){ R[ S.top() ] = i; S.pop(); } L[i] = S.size() ? S.top() : -1; S.push(i); } for(; S.size() ;){ R[ S.top() ] = n; S.pop(); } return f(0,n-1,lef,rig); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...