Submission #482924

#TimeUsernameProblemLanguageResultExecution timeMemory
482924Blistering_BarnaclesSecret (JOI14_secret)C++11
100 / 100
438 ms17412 KiB
#include "secret.h" //apig's property //Happiness can be found, even in the darkest of times, if one only remembers to turn on the light //El Pueblo Unido Jamas Sera Vencido //Do or do not... there is no try //Billions of bilious blue blistering barnacles in a thundering typhoon! #include<bits/stdc++.h> #define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) #define F first #define S second #define pb push_back #define vll vector< ll > #define vi vector< int > #define pll pair< ll , ll > #define pi pair< int , int > #define all(s) s.begin() , s.end() #define sz(s) s.size() #define str string #define md ((s + e) / 2) //#define mid ((l + r) / 2) #define msdp(dp) memset(dp , -1 , sizeof dp) #define mscl(dp) memset(dp , 0 , sizeof dp) #define C continue #define R return #define B break #define lx node * 2 #define rx node * 2 + 1 #define br(o) o ; break #define co(o) o ; continue using namespace std; typedef int ll; ll q, dp[300005][20] , a[555555] , mask[555555], k, l, m, n, o, p; map < ll , ll > mp; vll adj[555555]; const ll mod = 1e9+7; str s; void div(ll l , ll r , ll lev){ if(l == r)R ; ll mid = (r + l) / 2 ; dp[mid][lev] = a[mid] ; for(ll i = mid - 1 ; i >= l ; i--){ dp[i][lev] = Secret(a[i] , dp[i + 1][lev]) ; } dp[mid + 1][lev] = a[mid + 1] ; for(ll i = mid + 2 ; i <= r ; i++){ dp[i][lev] = Secret(dp[i - 1][lev] , a[i]) ; } for(ll i = mid + 1 ; i <= r ; i++)mask[i] ^= (1 << lev) ; div(l , mid , lev + 1) , div(mid + 1 , r , lev + 1) ; } void Init(int N, int A[]) { n = N ; for(ll i = 0 ; i < n ; i++){ a[i] = A[i] ; } div(0 , n - 1 , 0) ; } int Query(int l, int r) { if(l == r)R a[r] ; ll bits = __builtin_ctz(mask[l] ^ mask[r]) ; R Secret(dp[l][bits] , dp[r][bits]) ; }
#Verdict Execution timeMemoryGrader output
Fetching results...