Submission #1055250

# Submission time Handle Problem Language Result Execution time Memory
1055250 2024-08-12T15:56:20 Z phong Secret (JOI14_secret) C++17
0 / 100
258 ms 14956 KB
#include<bits/stdc++.h>
#include "secret.h"

#define ll long long
const int nmax =  1e3+ 5;

using namespace std;

int n, a[nmax];
int L[1 << 12][nmax], R[1 << 12][nmax];
//int Secret(int a, int b){
//    if(a > b) swap(a, b);
//    if(a == 4 && b == 7) return 10;
//    if(a == 1 && b == 10) return 11;
//    if(a == 2 && b == 11) return 13;
//    return 0;
//}

void build(int id, int l, int r){
    if(l == r)return;
    int mid = r + l >> 1;
    L[id][mid] = a[mid];
    R[id][mid + 1] = a[mid + 1];
    for(int i = mid - 1; i >= l; --i) L[id][i] = Secret(L[id][i + 1], a[i]);
    for(int i = mid + 2; i <= r; ++i) R[id][i] = Secret(R[id][i - 1], a[i]);
    build(id << 1, l, mid);
    build(id << 1 | 1, mid + 1, r);
}

int get(int id, int l, int r, int u, int v){
    if(u == v) return a[u];
    if(l > v || r < u) return 0;

    int mid = r + l >> 1;
	if(v == mid) return L[id][u];
	if(u == mid + 1) return R[id][v];
    if(u <= mid && mid + 1 <= v){
        return Secret(L[id][u], R[id][v]);
    }
    return get(id << 1, l, mid, u, v) + get(id << 1 | 1, mid + 1, r, u, v);
}
void Init(int NA, int A[]){
    n = NA;
    for(int i = 0; i < n; ++i) a[i] = A[i];
    build(1, 0, n - 1);
}
int Query(int l, int r){
    return get(1, 0, n - 1, l, r);
}

Compilation message

secret.cpp: In function 'void build(int, int, int)':
secret.cpp:21:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   21 |     int mid = r + l >> 1;
      |               ~~^~~
secret.cpp: In function 'int get(int, int, int, int, int)':
secret.cpp:34:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |     int mid = r + l >> 1;
      |               ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 10832 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 66 ms 10804 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 68 ms 10856 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 253 ms 14928 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 258 ms 14940 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 253 ms 14928 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 254 ms 14952 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 256 ms 14956 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 253 ms 14932 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 257 ms 14936 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.