Submission #703803

#TimeUsernameProblemLanguageResultExecution timeMemory
703803TS_2392Secret (JOI14_secret)C++14
Compilation error
0 ms0 KiB
#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 (stderr)

secret.cpp: In function 'void dnc(int, int)':
secret.cpp:12:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   12 |     int mid = L + R >> 1;
      |               ~~^~~
secret.cpp: At global scope:
secret.cpp:18:24: error: expected ',' or '...' before 'A'
   18 | void Init(int N, int[] A){
      |                        ^
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:20:40: error: 'A' was not declared in this scope
   20 |     for(int i = 1; i <= n; ++i) a[i] = A[i - 1];
      |                                        ^