# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
703800 |
2023-02-28T12:15:51 Z |
TS_2392 |
Secret (JOI14_secret) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int NN = 1002;
int n, a[NN], calc[NN][NN];
int Secret(int x, int y){
return x + (y / 2) * 2;
}
void dnc(int L, int R){
if(L + 1 >= R) return;
int mid = L + R >> 1;
calc[mid][mid] = a[mid], calc[mid + 1][mid + 1] = a[mid + 1];
for(int i = mid - 1; i >= L; --i) calc[i][mid] = Secret(a[i], calc[i + 1][mid]);
for(int i = mid + 2; i <= R; ++i) calc[mid + 1][i] = Secret(calc[mid + 1][i - 1], a[i]);
dnc(L, mid); dnc(mid + 1, R);
}
void Init(int N, int A[])
{
n = N;
for(int i = 1; i <= n; ++i) a[i] = A[i - 1];
memset(calc, 255, sizeof(calc)); dnc(1, n);
}
int Query(int L, int R)
{
++L; ++R;
if(L == R) return a[L];
if(L + 1 == R) return Secret(a[L], a[R]);
int i;
for(i = L; i < R; ++i) if(calc[L][i] != -1 && calc[i + 1][R] != -1) break;
return Secret(calc[L][i], calc[i + 1][R]);
}
Compilation message
secret.cpp: In function 'void dnc(int, int)':
secret.cpp:12:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
12 | int mid = L + R >> 1;
| ~~^~~
/usr/bin/ld: /tmp/ccB4X6pz.o: in function `Secret(int, int)':
secret.cpp:(.text+0x0): multiple definition of `Secret(int, int)'; /tmp/ccgVyecy.o:grader-full.cpp:(.text+0x2d0): first defined here
collect2: error: ld returned 1 exit status