# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109192 |
2019-05-05T12:08:22 Z |
maruii |
Secret (JOI14_secret) |
C++14 |
|
577 ms |
4600 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define ff first
#define ss second
int N, *A;
vector<pii> vec[1001];
void f(int s, int e){
int m = s+e>>1;
vec[m+1].emplace_back(m+1, A[m+1]);
for(int i=m+2, t=A[m+1]; i<=e; ++i){
t = Secret(t, A[i]);
vec[m+1].emplace_back(i, t);
}
vec[m].emplace_back(m, A[m]);
for(int i=m-1, t=A[m]; i>=s; --i){
t = Secret(A[i], t);
vec[i].emplace_back(m, t);
}
if(e-s<2) return;
f(s, m), f(m+1, e);
}
int g(int s, int e, int L, int R){
if(e<L || R<s) return 0;
int m = s+e>>1;
if(L<=m && m<R) return Secret(lower_bound(vec[L].begin(), vec[L].end(), pii(m, 0))->ss, lower_bound(vec[m+1].begin(), vec[m+1].end(), pii(R, 0))->ss);
return g(s, m, L, R) | g(m+1, e, L, R);
}
void Init(int N_, int A_[]){
N = N_, A = A_;
f(0, N-1);
for(int i=0; i<N; ++i) sort(vec[i].begin(), vec[i].end());
}
int Query(int L, int R){
if(L==R) return A[L];
return g(0, N-1, L, R);
}
Compilation message
secret.cpp: In function 'void f(int, int)':
secret.cpp:10:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m = s+e>>1;
~^~
secret.cpp: In function 'int g(int, int, int, int)':
secret.cpp:26:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m = s+e>>1;
~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
2552 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
162 ms |
2524 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
157 ms |
2552 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
520 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
529 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
515 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
521 ms |
4588 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
538 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
548 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
577 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |