Submission #377779

# Submission time Handle Problem Language Result Execution time Memory
377779 2021-03-15T04:45:01 Z rrrr10000 Secret (JOI14_secret) C++14
100 / 100
509 ms 4716 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(int i=0;i<(int)(n);i++)
#define REP(i,k,n) for(int i=k;i<(int)(n);i++)
#define pb emplace_back
#define lb(v,k) (lower_bound(all(v),(k))-v.begin())
#define ub(v,k) (upper_bound(all(v),(k))-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define all(a) a.begin(),a.end()
#define rsort(a) {sort(all(a));reverse(all(a));}
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef int ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void outset(T s){auto itr=s.begin();while(itr!=s.end()){if(itr!=s.begin())cout<<' ';cout<<*itr;itr++;}cout<<'\n';}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
#include "secret.h"
vvi tl,tr;
vi A;
ll n_;
void Init(int n, int a[]){
    n_=n;
    tl=vvi(n);tr=vvi(n);
    rep(i,n)A.pb(a[i]);
    function<void(ll,ll)> dfs=[&](ll l,ll r){
        if(r-l<=1)return;
        ll md=(l+r+1)/2;
        ll k=a[md];tr[md].pb(k);
        for(int i=md+1;i<=r;i++){
            k=Secret(k,a[i]);
            tr[md].pb(k);
        }
        k=a[md-1];tl[md].pb(k);
        for(int i=md-2;i>=l;i--){
            k=Secret(a[i],k);
            tl[md].pb(k);
        }
        dfs(l,md-2);dfs(md+1,r);
    };dfs(0,n-1);
}

int Query(int L,int R){
    if(L==R)return A[L];
    if(R-L==1)return Secret(A[L],A[R]);
    function<int(ll,ll)> dfs=[&](ll l,ll r){
        ll md=(l+r+1)/2;
        if(md+1<=L)return dfs(md+1,r);
        if(md-2>=R)return dfs(l,md-2);
        if(md==L)return tr[md][R-L];
        if(md-1==R)return tl[md][R-L];
        return Secret(tl[md][md-1-L],tr[md][R-md]);
    };return dfs(0,n_-1);
}

Compilation message

secret.cpp:30:14: warning: overflow in conversion from 'long int' to 'll' {aka 'int'} changes value from '1001001001001001001' to '1551474729' [-Woverflow]
   30 | const ll inf=1001001001001001001;
      |              ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 143 ms 2668 KB Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1
2 Correct 141 ms 2540 KB Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1
3 Correct 142 ms 2540 KB Output is correct - number of calls to Secret by Init = 3100, maximum number of calls to Secret by Query = 1
4 Correct 509 ms 4460 KB Output is correct - number of calls to Secret by Init = 6988, maximum number of calls to Secret by Query = 1
5 Correct 508 ms 4460 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
6 Correct 500 ms 4588 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
7 Correct 507 ms 4588 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
8 Correct 506 ms 4588 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
9 Correct 504 ms 4716 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
10 Correct 507 ms 4460 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1