Submission #366670

# Submission time Handle Problem Language Result Execution time Memory
366670 2021-02-14T22:42:12 Z iliccmarko Secret (JOI14_secret) C++14
0 / 100
513 ms 8524 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 1005;
int a[N][N];
int arr[N];
int n;

void build(int l, int r)
{
    if(r-l<=1) return;
    int mid = (l+r)/2;
    ll val = arr[mid];
    for(int i = mid-1;i>=l;i--)
    {
        val = Secret(val, arr[i]);
        a[i][mid] = val;
    }
    val = arr[mid+1];
    for(int i = mid+2;i<=r;i++)
    {
        val = Secret(val, arr[i]);
        a[mid+1][i] = val;
    }
    build(l, mid);
    build(mid+1, r);
}

void Init(int N, int w[])
{
    n = N;
    for(int i = 0;i<n;i++)
        for(int j = 0;j<n;j++)
        a[i][j] = -1;
    for(int i = 0;i<n;i++) arr[i] = w[i];
    for(int i = 0;i<n;i++) a[i][i] = arr[i];
    build(0, n-1);
}

int resi(int l, int r, int i, int j)
{
    int mid = (i+j)/2;
    if(l<=mid&&r>mid)
    {
        return Secret(a[l][mid], a[mid+1][r]);
    }
    if(r==mid) return a[l][mid];
    if(l==mid+1) return a[mid+1][r];
    if(l>mid) return resi(l, r, mid+1, j);
    else return resi(l, r, i, mid);
}

int Query(int l, int r)
{
    if(l==r) return arr[l];
    if(l==(r-1)) return Secret(arr[l], arr[r]);
    return resi(l, r, 0, n-1);
}


# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 4460 KB Wrong Answer: Query(113, 206) - expected : 536899947, actual : 538256673.
2 Incorrect 132 ms 4460 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 133 ms 4460 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 495 ms 8300 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 495 ms 8228 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 493 ms 8204 KB Wrong Answer: Query(811, 813) - expected : 25091616, actual : 678362320.
7 Incorrect 501 ms 8524 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 513 ms 8300 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 493 ms 8300 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 502 ms 8228 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.