# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
466079 |
2021-08-17T20:44:09 Z |
nickmet2004 |
popa (BOI18_popa) |
C++11 |
|
141 ms |
328 KB |
#include<bits/stdc++.h>
#include "popa.h"
using namespace std;
/*
int query(int a , int b , int l , int r){
int k =s[a];
for(int i = a+1; i<= b; ++i)k = __gcd(k , s[i]);
int j = s[l];
for(int i = l + 1; i <= r; ++i)j = __gcd(j , s[i]);
return k == j;
}
*/
int solve(int n , int *Left , int *Right) {
stack<int> st;
int root = 0;
for(int i = 0; i < n; ++i)Left[i] = Right[i] = -1;
st.push(0);
for(int i =1; i < n; ++i){
while(st.size() && query(st.top() , i , i , i)){
Right[st.top()] = Left[i];
Left[i] = st.top();
st.pop();
}
if(st.size()) Right[st.top()] = i;
else root = i;
st.push(i);
}
return root;
}
/*
int main (){
int n;
cin >> n;
for(int i = 0; i< n; ++i)cin >> s[i];
memset(Left , -1 , sizeof(Left));memset(Right , -1 , sizeof(Right));
cout << solve(n)<<endl;
for(int i = 0; i < n; ++i)cout << Left[i] << " " << Right[i] << endl;
}
*/
///20 80 40
///40 80 20
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
200 KB |
Output is correct |
2 |
Correct |
5 ms |
200 KB |
Output is correct |
3 |
Correct |
9 ms |
328 KB |
Output is correct |
4 |
Correct |
13 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
141 ms |
280 KB |
Output is correct |
2 |
Correct |
132 ms |
284 KB |
Output is correct |
3 |
Correct |
71 ms |
300 KB |
Output is correct |
4 |
Correct |
114 ms |
280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
284 KB |
Output is correct |
2 |
Correct |
132 ms |
320 KB |
Output is correct |
3 |
Correct |
103 ms |
284 KB |
Output is correct |
4 |
Correct |
127 ms |
284 KB |
Output is correct |