Submission #735272

# Submission time Handle Problem Language Result Execution time Memory
735272 2023-05-03T19:47:16 Z Wael Secret (JOI14_secret) C++14
6 / 100
8321 ms 8392 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int long long
#define F first
#define S second
//#define endl '\n'
#define INT INT_MAX
int const M = 1e3 + 25 , N = 3e6 , lg = 25 , mod = 1e9 + 7;
int dx[] = {0 , 0 , -1 , 1 , 1 , 1 , -1 , -1};
int dy[] = {1 , -1 , 0 , 0 , 1 , -1 , 1 , -1};
int T , n , j , ans[M][M] , a[M] , Q , l , r , Size , s[M];
/*
inline ll Secret(int x , int y) {
    //cout << x << " " << y << endl;
    int res;
    res = x + y;
    return res;
}
*/

void Go(int x = 1 , int lx = 1 , int rx = Size) {

    if(lx == rx) {
        ans[lx][rx] = s[lx];
        return;
    }
    int mid = (lx + rx) / 2;
    int a = mid , b = mid + 1;
    ans[b][b] = s[b];
    for(int i = b + 1 ; i <= rx ; ++i) ans[b][i] = Secret(ans[b][i - 1] , s[i]);

    ans[a][a] = s[a];
    if(a <= n) for(int i = a - 1 ; i >= lx ; --i) ans[i][a] = Secret(ans[i + 1][a] , s[i]);
    Go(2 * x , lx , mid);
    Go(2 * x + 1 , mid + 1 , rx);

}

int Get(int l , int r , int x = 1 , int lx = 1 , int rx = Size) {

    int mid = (lx + rx) / 2;
    if(lx == rx) return s[lx];
    if(mid >= l && mid <= r) return Secret(ans[l][mid] , ans[mid + 1][r]);
    if(l > mid) return Get(l , r , 2 * x + 1 , mid + 1 , rx);
    else return Get(l , r , 2 * x,  lx , mid);

}

void Init(int sz , int ar[]) {

    n = sz;
    for(int i = n ; i >= 1 ; --i) s[i] = ar[i - 1];
    Size = (1 << 10);
    Go();

}

int Query(int l , int r) {
    ++l , ++r;
  	int res = s[l];
	for(int i = l + 1 ; i <= r ; ++i) res = Secret(res , s[i]);  
    return res;

}
/*
main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);


    return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Partially correct 1591 ms 6472 KB Output isn't correct - number of calls to Secret by Init = 5890, maximum number of calls to Secret by Query = 506
2 Partially correct 1537 ms 6476 KB Output isn't correct - number of calls to Secret by Init = 6401, maximum number of calls to Secret by Query = 508
3 Partially correct 1604 ms 6604 KB Output isn't correct - number of calls to Secret by Init = 6401, maximum number of calls to Secret by Query = 505
4 Partially correct 3322 ms 8384 KB Output isn't correct - number of calls to Secret by Init = 8150, maximum number of calls to Secret by Query = 997
5 Partially correct 3318 ms 8368 KB Output isn't correct - number of calls to Secret by Init = 8157, maximum number of calls to Secret by Query = 992
6 Partially correct 470 ms 8364 KB Output isn't correct - number of calls to Secret by Init = 8157, maximum number of calls to Secret by Query = 10
7 Partially correct 8145 ms 8384 KB Output isn't correct - number of calls to Secret by Init = 8157, maximum number of calls to Secret by Query = 999
8 Partially correct 7964 ms 8268 KB Output isn't correct - number of calls to Secret by Init = 8157, maximum number of calls to Secret by Query = 999
9 Partially correct 7784 ms 8392 KB Output isn't correct - number of calls to Secret by Init = 8157, maximum number of calls to Secret by Query = 998
10 Partially correct 8321 ms 8384 KB Output isn't correct - number of calls to Secret by Init = 8157, maximum number of calls to Secret by Query = 999