Submission #302001

# Submission time Handle Problem Language Result Execution time Memory
302001 2020-09-18T11:04:35 Z aloo123 Secret (JOI14_secret) C++14
0 / 100
509 ms 8448 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 = 1e9;
const int M =(1e3+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
int a[M];
int n;
int pref[M][M];
// int Secret(int x,int y){
//     return min(x+2*(y/2),1000000000);
// }
void divi(int l, int r) { // generate dat and mask
    // cout << l << " " << r << endl;
    // if(l < 1 || r > n || l > r) return;
    // if (l == r) {pref[l][l] = a[l];return;}

    int m = (l+r)/2; 
    pref[m][m] = a[m];
    for(int i = m-1;i>=l;i--){
        pref[i][m] = Secret(a[i],pref[i+1][m]); 
    }
    pref[m+1][m+1] = a[m+1];
    for(int i = m+2;i<=r;i++){
        pref[m+1][i] = Secret(pref[m+1][i-1],a[i]);
    }
    
    if(l < m)
        divi(l,m);
    if((m+1) < r)
        divi(m+1,r);
}

 
 
void Init(int N,int A[]){
    n = N;
    for(int i = 0;i<n;i++){
        a[i+1] = A[i];
    }
    divi(1,n);
 
}
int Query(int L, int R){
        int a = 1, b = n;
        L++,R++;
    while (a != b) {
        int mid = (a + b) / 2;
        if (mid >= L && mid < R)
            return Secret(pref[mid][L], pref[mid + 1][R]);
        else if (mid == R) return pref[mid][L];
        else if (mid < L) a = mid + 1;
        else b = mid;
    }

    return pref[a][a];
}

 
 
// void solve(){
    
// // }
// signed main(){
 
//     ios_base::sync_with_stdio(0);
//     // cin.tie(NULL);
//      // freopen(".in","r",stdin);freopen(".out","w",stdout);
//     int x;
//     cin >> x;
//     int v[x];
//     for(int i =0;i<x;i++){
//         cin >> v[i];
//     }
//     Init(x,v);
//     int q;
//     cin >> q;
//     while(q--){
//         int l,r;
//         cin>>l>>r;
//         cout<<Query(l,r)<<endl;
//     }
         
// }
# Verdict Execution time Memory Grader output
1 Incorrect 143 ms 4472 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 860971434.
2 Incorrect 135 ms 4472 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 712055264.
3 Incorrect 138 ms 4472 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 539361598.
4 Incorrect 502 ms 8368 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 374358039.
5 Incorrect 500 ms 8440 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 483966986.
6 Incorrect 501 ms 8312 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 3875264.
7 Incorrect 509 ms 8448 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 177907722.
8 Incorrect 502 ms 8368 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 489869504.
9 Incorrect 500 ms 8416 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 702032905.
10 Incorrect 508 ms 8312 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 336488262.