Submission #735286

#TimeUsernameProblemLanguageResultExecution timeMemory
735286WaelSecret (JOI14_secret)C++14
Compilation error
0 ms0 KiB
#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 + 30 , 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 , a[M] , Q , l , r , Size = 1024 , s[M]; long long ans[M][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]; 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((mid >= l && mid <= r)) return { int res = 0; if(mid >= l && mid + 1 <= r) res = Secret(ans[l][mid] , ans[mid + 1][r]); else if(mid == r) res = ans[l][mid]; return res; } 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 = 1 ; i <= n ; ++i) s[i] = ar[i - 1]; Go(); } int Query(int l , int r) { ++l , ++r; if(l == r) return s[l]; return Get(l , r); }

Compilation message (stderr)

secret.cpp: In function 'int Get(int, int, int, int, int)':
secret.cpp:47:9: error: expected primary-expression before 'int'
   47 |         int res = 0;
      |         ^~~
secret.cpp:47:9: error: expected '}' before 'int'
secret.cpp:46:39: note: to match this '{'
   46 |     if((mid >= l && mid <= r)) return {
      |                                       ^
secret.cpp:47:9: error: cannot convert '<brace-enclosed initializer list>' to 'int' in return
   47 |         int res = 0;
      |         ^~~
secret.cpp:46:40: error: expected ';' before 'int'
   46 |     if((mid >= l && mid <= r)) return {
      |                                        ^
      |                                        ;
   47 |         int res = 0;
      |         ~~~                             
secret.cpp: At global scope:
secret.cpp:52:5: error: expected unqualified-id before 'if'
   52 |     if(l > mid) return Get(l , r , 2 * x + 1 , mid + 1 , rx);
      |     ^~
secret.cpp:53:5: error: expected unqualified-id before 'else'
   53 |     else return Get(l , r , 2 * x,  lx , mid);
      |     ^~~~
secret.cpp:55:1: error: expected declaration before '}' token
   55 | }
      | ^