# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
423657 |
2021-06-11T10:59:24 Z |
egekabas |
popa (BOI18_popa) |
C++14 |
|
284 ms |
324 KB |
#include <bits/stdc++.h>
#include "popa.h"
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
/*int ar[10009];
int query(int a, int b, int c, int d){
int v1 = 0, v2 = 0;
for(int i = a; i <= b; ++i)
v1 = __gcd(v1, ar[i]);
for(int i = c; i <= d; ++i)
v2 = __gcd(v2, ar[i]);
return v1 == v2;
}*/
int merge(int l, int r, int *Left, int *Right){
if(l == -1)
return r;
if(r == -1)
return l;
if(query(l, r, l, l)){
Right[l] = merge(Right[l], r, Left, Right);
return l;
}
else{
Left[r] = merge(l, Left[r], Left, Right);
return r;
}
}
int calc(int l, int r, int *Left, int *Right){
if(l == r)
return l;
int m = (l+r)/2;
int v1 = calc(l, m, Left, Right);
int v2 = calc(m+1, r, Left, Right);
return merge(v1, v2, Left, Right);
}
int solve(int N, int *Left, int *Right){
for(int i = 0; i < N; ++i)
Left[i] = Right[i] = -1;
return calc(0, N-1, Left, Right);
}
/*int L[1009], R[1009];
int main(){
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
int n;
cin >> n;
for(int i = 0; i < n; ++i)
cin >> ar[i];
cout << solve(n, L, R) << '\n';
for(int i = 0; i < n; ++i)
cout << i << ' ' << L[i] << ' ' << R[i] << '\n';
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
200 KB |
Output is correct |
2 |
Correct |
15 ms |
200 KB |
Output is correct |
3 |
Correct |
13 ms |
200 KB |
Output is correct |
4 |
Correct |
18 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
205 ms |
324 KB |
Output is correct |
2 |
Correct |
284 ms |
320 KB |
Output is correct |
3 |
Correct |
95 ms |
320 KB |
Output is correct |
4 |
Correct |
175 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
88 ms |
276 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |