답안 #934987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
934987 2024-02-28T09:47:42 Z vjudge1 비밀 (JOI14_secret) C++17
0 / 100
392 ms 11600 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 = 1000;
ll a[maxn];
ll n = 1000;
ll ans[maxn][maxn];
/////////////////////
//FUNS
void f(ll L, ll R)
{
	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(0 , n-1);
}

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: 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];
      |  ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 101 ms 8888 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 116 ms 8788 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 101 ms 8788 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 373 ms 11440 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 372 ms 11440 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 374 ms 11436 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 379 ms 11432 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 377 ms 11600 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 392 ms 11428 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 374 ms 11428 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.