# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
301668 |
2020-09-18T05:51:46 Z |
aloo123 |
Secret (JOI14_secret) |
C++14 |
|
1000 ms |
4728 KB |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#include "secret.h"
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
// #define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
const ll INF = 1e12;
const int M =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
int a[M];
int n;
int dat[18][M], mask[M];
void divi(int l, int r, int lev) { // generate dat and mask
if (l == r) return;
int m = (l+r)/2;
dat[lev][m] = a[m];
for(int i = m-1;i>=1;i--) dat[lev][i] = Secret(a[i],dat[lev][i+1]);
dat[lev][m+1] = a[m+1];
for(int i = m+2;i<=r;i++) dat[lev][i] = Secret(dat[lev][i-1],a[i]);
for(int i = m+1;i<=r;i++) mask[i] ^= 1<<lev;
divi(l,m,lev+1); divi(m+1,r,lev+1);
}
void Init(int N,int A[]){
n = N;
for(int i = 0;i<n;i++){
a[i+1] = A[i];
}
divi(1,n,0);
}
int Query(int L, int R){
L++,R++;
if(L == R){
return a[L];
}
int bits = __builtin_ctz(mask[L]^mask[R]);
return Secret(dat[bits][L],dat[bits][R]);
}
// void solve(){
// }
// signed main(){
// ios_base::sync_with_stdio(0);
// cin.tie(NULL);
// // freopen(".in","r",stdin);freopen(".out","w",stdout);
// ll tt=1;
// // cin >> tt;
// while(tt--){
// solve();
// }
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
261 ms |
2428 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 857017776. |
2 |
Incorrect |
259 ms |
2424 KB |
Wrong Answer: Query(102, 157) - expected : 32612619, actual : 910332073. |
3 |
Incorrect |
262 ms |
2424 KB |
Wrong Answer: Query(334, 369) - expected : 363022362, actual : 606595196. |
4 |
Incorrect |
974 ms |
4728 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 638075635. |
5 |
Incorrect |
969 ms |
4600 KB |
Wrong Answer: Query(263, 292) - expected : 653448456, actual : 960497996. |
6 |
Incorrect |
978 ms |
4344 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 153789057. |
7 |
Partially correct |
991 ms |
4600 KB |
Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1 |
8 |
Partially correct |
992 ms |
4728 KB |
Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1 |
9 |
Partially correct |
991 ms |
4344 KB |
Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1 |
10 |
Partially correct |
1000 ms |
4472 KB |
Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1 |