Submission #1269850

#TimeUsernameProblemLanguageResultExecution timeMemory
1269850faricapopa (BOI18_popa)C++20
100 / 100
25 ms424 KiB
#include <bits/stdc++.h>
#include "popa.h"

using namespace std;

int solve(int N, int* Left, int* Right) {
  stack<int>s;
  s.push(0);
  for(int i=0; i<N; ++i) Left[i] = Right[i] = -1;
  for(int i=1; i<N; ++i) {
    int prv = -1;
    while(!s.empty() && query(s.top(), i, i, i)) {
      prv = s.top();
      s.pop();
    }
    Left[i] = prv;
    if(!s.empty()) Right[s.top()] = i;
    s.push(i);
  }
  while(s.size() > 1) s.pop();
  return s.top();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...