Submission #645756

#TimeUsernameProblemLanguageResultExecution timeMemory
645756Kriptonpopa (BOI18_popa)C++14
100 / 100
93 ms444 KiB
#include <bits/stdc++.h> #include "popa.h" using namespace std; int st[1001],dr[1001]; int maxst[1001]; int solutioneaza(int sta,int dre) { if(sta==dre) return sta; for(int i=dre;i>=sta;i--) if(maxst[i]<=sta) { if(i!=sta) st[i]=solutioneaza(sta,i-1); if(i!=dre) dr[i]=solutioneaza(i+1,dre); return i; } return -1; } int solve(int n,int *Left, int *Right) { for(int i=0;i<n;i++) { st[i]=dr[i]=-1; maxst[i]=i-1; } for(int i=0;i<n;i++) while(maxst[i]!=-1&&query(maxst[i],i,i,i)) maxst[i]=maxst[maxst[i]]; for(int i=0;i<n;i++) maxst[i]++; int x=solutioneaza(0,n-1); for(int i=0;i<n;i++) { Left[i]=st[i]; Right[i]=dr[i]; } return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...