Submission #525530

# Submission time Handle Problem Language Result Execution time Memory
525530 2022-02-11T21:46:19 Z omohamadooo Secret (JOI14_secret) C++14
0 / 100
437 ms 24076 KB
#include "secret.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl '\n'
#define pii pair<ll,ll >
#define F first
#define S second
#define double long double
#define all(x) (x).begin(),(x).end()
using namespace std;
using namespace __gnu_pbds;

typedef tree<ll , null_type , less_equal<ll> ,rb_tree_tag ,tree_order_statistics_node_update >ordered_set;

const int MOD=998244353 ;
const int  N=1e6+ 7;
const ll INF= 1e18+10;

struct trp{ll F,S,T;};

ll po(ll x,ll y)
{
    ll ans = 1;
    while(y){
        if( y & 1 ) ans *=x;
        y /= 2;
        x *=x;
        x %= MOD;
        ans %= MOD;
    }
    return ans;
}

int n;
vector<int>v;
int pref[1005][1005],suf[1005][1005];

void build(ll id,ll l,ll r)
{
    if(l == r) return;
    ll m = (l + r)/2;
    suf[id][m] = v[m];
    pref[id][m+1] = v[m+1];
    for(ll i=m-1;i>=l;i--){
        suf[id][i] = Secret(suf[id][i+1] , v[i]);
    }
    for(ll i=m+2;i<=r;i++){
        pref[id][i] = Secret(pref[id][i-1] , v[i]);
    }
    build(id*2+1,l,m);
    build(id*2+2,m+1,r);
}

void Init(int f , int *a)
{
    n = f;
    for(ll i=0;i<n;i++) v.pb(a[i]);
    build(0,0,n-1);
}

ll get_ans(ll id,ll segl,ll segr,ll l,ll r)
{
    if(segl == segr) assert(0);
    ll m = (segl + segr)/2;
    if(r <= m) return get_ans(id*2+2,segl,m,l,r);
    else if(l > m) return get_ans(id*2+1,m+1,segr,l,r);
    return Secret(suf[id][l] , pref[id][r]);
}

int Query(int l, int r)
{
    if(l ==  r) return v[l];
    return get_ans(0,0,n-1 , l,r);
}
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 6312 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 536870912.
2 Incorrect 119 ms 6444 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 111 ms 6340 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Runtime error 437 ms 23964 KB Execution killed with signal 11
5 Runtime error 433 ms 24000 KB Execution killed with signal 11
6 Runtime error 430 ms 23976 KB Execution killed with signal 11
7 Runtime error 435 ms 24076 KB Execution killed with signal 11
8 Runtime error 433 ms 24004 KB Execution killed with signal 11
9 Runtime error 434 ms 24040 KB Execution killed with signal 11
10 Runtime error 436 ms 24064 KB Execution killed with signal 11