#include "popa.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
int qry(int x, int y){
return query(x, x, min(x, y), max(x, y));
}
int solve(int n, int l[], int r[]){
stack<int> stk;
for(int i = 0; i < n; i++){
int x;
l[i] = r[i] = -1;
while(!stk.empty() && qry(i, x = stk.top())){
l[i] = x;
stk.pop();
}
if(!stk.empty()){
//if(!qry(x = stk.top(), i)) return -1;
r[x] = i;
}
stk.push(i);
}
while(stk.size() > 1) stk.pop();
return stk.top();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
256 KB |
Output is correct |
2 |
Correct |
9 ms |
256 KB |
Output is correct |
3 |
Correct |
9 ms |
256 KB |
Output is correct |
4 |
Correct |
11 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
372 KB |
Output is correct |
2 |
Correct |
83 ms |
384 KB |
Output is correct |
3 |
Correct |
80 ms |
380 KB |
Output is correct |
4 |
Correct |
104 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
376 KB |
Output is correct |
2 |
Correct |
110 ms |
380 KB |
Output is correct |
3 |
Correct |
106 ms |
376 KB |
Output is correct |
4 |
Correct |
91 ms |
376 KB |
Output is correct |