#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
// int gc(int a, int b){
// if(a==0 || b==0){
// return a+b;
// }
// return gc(b%a,a);
// }
// vector<int> inp;
// int query(int a, int b, int c, int d){
// int x = inp[a];
// int y = inp[c];
// for(int i = a; i<=b; i++){
// x = gc(x,inp[i]);
// }
// for(int i = c; i<=d; i++){
// y = gc(y,inp[i]);
// }
// return (x==y?1:0);
// }
vector<int> le;
vector<int> ri;
int f(int l, int r){
if(l>r){
return -1;
}
if(l==r){
le[l] = -1;
ri[r] = -1;
return l;
}
for(int i = l; i<=r; i++){
if(query(l,r,i,i)==1){
le[i] = f(l,i-1);
ri[i] = f(i+1,r);
return i;
}
}
assert(false);
return -69;
}
int solve(int n, int* left, int *right){
le.resize(n);
ri.resize(n);
int ret = f(0,n-1);
for(int i = 0; i<n; i++){
left[i] = le[i];
right[i] = ri[i];
}
return ret;
}
// int main(){
// inp.push_back(12);
// inp.push_back(4);
// inp.push_back(16);
// inp.push_back(2);
// inp.push_back(2);
// inp.push_back(20);
// int a[6];
// int b[6];
// cout << solve(6,a,b) << endl;
// for(int i = 0; i<6; i++){
// cout << a[i] << " ";
// }
// cout << endl;
// for(int i = 0; i<6; i++){
// cout << b[i] << " ";
// }
// cout << endl;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
296 KB |
Output is correct |
2 |
Correct |
123 ms |
436 KB |
Output is correct |
3 |
Correct |
25 ms |
436 KB |
Output is correct |
4 |
Correct |
93 ms |
532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
137 ms |
532 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
532 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |