# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
540768 | Wael | Secret (JOI14_secret) | C++14 | 20073 ms | 4348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define endl '\n'
int const M = (1 << 10);
set<pair<pair<ll , ll> , ll>>st;
ll val , size = 1 , l , r , t , x , y , n , m , s[M];
vector<ll>sum , op;
vector<ll>elem[3][M];
inline ll Ask(int x , int y) {
return Secret(x , y);
}
inline void Build(int x , int lx , int rx) {
int mid = (rx - lx + 1) / 2;
elem[1][x].push_back(s[mid]);
for(int i = mid - 1 ; i >= lx ; --i) {
ll res = Ask(s[i] , elem[1][x].back());
elem[1][x].push_back(res);
}
reverse(elem[1][x].begin() , elem[1][x].end());
elem[2][x].push_back(s[mid + 1]);
for(int i = mid + 2 ; i <= rx ; ++i) {
ll res = Ask(s[i] , elem[2][x].back());
}
}
inline ll Get(int l , int r , int x , int lx , int rx) {
int mid = (lx + rx) / 2;
if(mid >= l && mid <= r) {
ll val1 = elem[1][x][mid - l];
ll val2 = elem[2][x][r - mid];
return Ask(val1 , val2);
}
else if(mid + 1 >= l && mid + 1 <= r) {
ll val1 = elem[1][x][(mid + 1) - l];
ll val2 = elem[2][x][r - (mid + 1)];
return Ask(val1 , val2);
}
if(mid + 1 < l) return Get(l , r , 2 * x , lx , mid);
else return Get(l , r , 2 * x + 1 , mid + 1 , rx);
}
void Init(int N, int A[]) {
for(int i = 1 ; i <= N ; ++i) s[i] = A[i];
Build(1 , 1 , M);
}
int Query(int L, int R) {
cout << Get(L , R , 1 , 1 , size) << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |