답안 #570957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570957 2022-05-31T18:14:50 Z beaconmc 비밀 (JOI14_secret) C++14
0 / 100
20000 ms 8448 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
#define double long double
#include "secret.h"

using namespace std;

vector<vector<ll>> sus(129);
vector<ll> nums(129);
ll n;

// int Secret(ll a, ll b){
// 	return a+floor(b/2)*2;
// }

void sussy(ll a, ll b){
	if (b-a > 2){
		ll mid = (a+b)/2;

		vector<ll> left;
		vector<ll> right;

		left.push_back(nums[mid-1]);

		FORNEG(i, mid-2, a-1){
			left.push_back(Secret(nums[i], left[left.size()-1]));
		}

		right.push_back(nums[mid]);
		FOR(i,mid+1, b){
			right.push_back(Secret(right[right.size()-1], nums[i]));
		}

		reverse(left.begin(), left.end());

		for (auto&i : left){
			sus[mid].push_back(i);
		}

		for (auto&i : right){
			sus[mid].push_back(i);
		}

		sussy(a, mid);
		sussy(mid, b);
	}
}

void Init(int N, int A[]) {
	n = N;
	FOR(i,0,128) nums[i] = 1;

	FOR(i,0,N) nums[i] = A[i];

	sussy(0,128);
}

int Query(int L, int R){
	if (R == L+1){
		return Secret(nums[L], nums[R]);
	}
	ll lo = 0;
	ll hi = 128;

	while (lo<hi){
		ll mid = (lo+hi)/2;


		
		if (L<=mid && mid<R){


			ll size = sus[mid].size()/2;

			return Secret(sus[mid][size - (mid - L)], sus[mid][size+(R-mid)]);
		}

		if (mid<=L && mid<=R){
			lo = mid;
		}
		if (mid >= L && mid >= R){
			hi = mid;
		}
	}
}

// int main(){
// 	int sussy[8] =  {1,4,7,2,5,8,3,6};

// 	Init(8, sussy);




// }







Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:88:1: warning: control reaches end of non-void function [-Wreturn-type]
   88 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20036 ms 2252 KB Time limit exceeded
2 Runtime error 125 ms 4696 KB Execution killed with signal 6
3 Execution timed out 20025 ms 2380 KB Time limit exceeded
4 Incorrect 456 ms 4300 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 850395277.
5 Execution timed out 20044 ms 4268 KB Time limit exceeded
6 Execution timed out 20077 ms 4272 KB Time limit exceeded
7 Incorrect 463 ms 4296 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 695777331.
8 Incorrect 430 ms 4172 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 884244568.
9 Incorrect 435 ms 4216 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 541987396.
10 Runtime error 435 ms 8448 KB Execution killed with signal 6