This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// M
#include<bits/stdc++.h>
#include "popa.h"
using namespace std;
/*const int N = 1009;
vector < int > S;
int query(int a, int b, int c, int d)
{
int mn1 = INT_MAX;
int mn2 = INT_MAX;
for (int i = a; i <= b; i ++)
mn1 = min(mn1, S[i]);
for (int i = c; i <= d; i ++)
mn2 = min(mn2, S[i]);
return mn1 == mn2;
}*/
int solve(int n, int * L, int * R)
{
for (int i = 0; i < n; i ++)
L[i] = R[i] = -1;
vector < int > T;
T.push_back(0);
for (int i = 1; i < n; i ++)
{
int last = -1;
while (T.size() && query(T.back(), i, i, i))
last = T.back(), T.pop_back();
if (T.size())
R[T.back()] = i;
L[i] = last;
T.push_back(i);
}
return T[0];
}
/*int main()
{
int L[N], R[N];
int n;
scanf("%d", &n);
S = vector < int > (n, 0);
for (int &a : S)
scanf("%d", &a);
int root = solve(n, L, R);
printf("%d\n", root);
for (int i = 0; i < n; i ++)
printf("%d %d\n", L[i], R[i]);
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |