Submission #934970

# Submission time Handle Problem Language Result Execution time Memory
934970 2024-02-28T09:40:12 Z vjudge1 Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <secret.h>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back //emplace_back
#define pp pop_back
#define pii pair<ll, ll> //pair<int, int>
#define all(x) (x).begin(),(x).end()
#define mp(a,b) make_pair(a , b)
#define lb lower_bound
#define ub upper_bound
#define sz(x) (ll)(x).size()
#define F first
#define S second x) (x).begin()
#define For(x, n) for(int (x) = 0 ; (x) < (n) ; (x)++)
#define debug(x) cout << #x << " : " << x << endl << flush
#define endl '\n'
#define arr(x) array<ll , (x)>
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);

ll Sum(ll a , ll b , ll MOD)
{
 a %= MOD;
 b %= MOD;
 a += b;
 return a % MOD;
}

ll Mul(ll a , ll b , ll MOD)
{
 a %= MOD;
 b %= MOD;
 a *= b;
 return a % MOD;
}

ll Pow(ll a , ll b , ll MOD)
{
   ll res = 1;
   while(b)
   {
        if((b & 1))res = Mul(res , a , MOD);
     a = Mul(a , a , MOD);
     b >>= 1;
   }
   return res;
}

ll Min(ll a , ll b)
{
   if(a > b)return b;
   return a;
}

ll Max(ll a , ll b)
{
   if(a > b)return a;
   return b;
}

ll Ceil(ll a , ll b)
{
 if(b < 0)
  a *= -1, b *= -1;

 if(a < 0)return a/b;

 return(a + (b-1))/b;
}

/////////////////////
//VALS
const ll maxn = 1024;
ll a[maxn];
ll n;
ll ans[maxn][maxn];
/////////////////////
//FUNS
void f(ll L = 0; ll R = 1023)
{
	int mid = (L + R) / 2;
	ans[mid][mid] = a[mid];
	ans[mid + 1][mid + 1] = a[mid + 1];

	for (int i = mid + 2; i <= R; i++)
		ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], a[i]);
		
	for (int i = mid - 1; i >= L; i--)
		ans[mid][i] = Secret(ans[mid][i + 1], a[i]);

	if (L < mid) f(L, mid);
	if (mid + 1 < R) f(mid + 1, R);
}

void Init(int N, int A[]) 
{
	n = N;
	For(i,N)a[i] = A[i];
	
	f();
}

int Query(int L, int R) 
{
	int a = 0, b = n - 1;

	while (b - a >= 0) 
	{
		int mid = (a + b) >> 1;
		
		if (mid >= L && mid < R)
			return Secret(ans[mid][L], ans[mid + 1][R]);
		
		if(mid == R) return ans[mid][L];
		
		if (mid < L) a = mid + 1;
		else b = mid;
	}

	return ans[a][b];
}
/////////////////////
/*
ZZZZZZZ     A        M     M     IIIIIII  N     N
     Z     A A      M M   M M       I     NN    N
    Z     A   A    M   M M   M      I     N N   N
   Z     AAAAAAA  M     M     M     I     N  N  N
  Z      A     A  M           M     I     N   N N
 Z       A     A  M           M     I     N    NN
ZZZZZZZ  A     A  M           M  IIIIIII  N     N  TREE
*/

Compilation message

secret.cpp:84:16: error: expected ')' before ';' token
   84 | void f(ll L = 0; ll R = 1023)
      |       ~        ^
      |                )
secret.cpp:84:29: error: expected ',' or ';' before ')' token
   84 | void f(ll L = 0; ll R = 1023)
      |                             ^
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:18:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define For(x, n) for(int (x) = 0 ; (x) < (n) ; (x)++)
      |                           ^
secret.cpp:103:2: note: in expansion of macro 'For'
  103 |  For(i,N)a[i] = A[i];
      |  ^~~