답안 #381640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381640 2021-03-25T12:10:20 Z flappybird 비밀 (JOI14_secret) C++14
0 / 100
547 ms 12396 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
#define MAX 1010

struct range {
	ll x, y;
	ll v;
};

vector<range> vv;
vector<ll> a;
ll arr1[MAX][MAX];
ll arr2[MAX][MAX];

void init(ll low, ll high) {
	if (low >= high) return;
	ll mid = (low + high) / 2;
	vv.push_back({ low, high, mid });
	init(low, mid);
	init(mid + 1, high);
}

void Init(int N, int A[]) {
	init(1, N);
	ll i, j;
	ll mid;
	a.resize(N + 1);
	for (i = 0; i < N; i++) a[i + 1] = A[i];
	for (i = 0; i < vv.size(); i++) {
		mid = vv[i].v;
		arr1[mid][mid] = A[mid - 1];
		for (j = mid - 1; j >= vv[i].x; j--) arr1[mid][j] = Secret(A[j - 1], arr1[mid][j + 1]);
		if (mid + 1 <= vv[i].y) arr2[mid][mid + 1] = A[j + 1];
		for (j = mid + 2; j <= vv[i].y; j++) arr2[mid][j] = Secret(arr2[mid][j - 1], A[j - 1]);
	}
}

int Query(int L, int R) {
	ll i;
	L++;
	R++;
	if (L == R) return a[L];
	if (R - L == 1) return Secret(a[L], a[R]);
	ll m = 0;
	ll aa;
	aa = 0;
	for (i = 0; i < vv.size(); i++) {
		if (vv[i].x <= L && R <= vv[i].y) {
			if (m < vv[i].y - vv[i].x) {
				m = vv[i].y - vv[i].x;
				aa = i;
			}
		}
	}
	if (vv[aa].v == L) return Secret(a[L], arr2[vv[aa].v][R]);
	if (vv[aa].v == R) return arr1[vv[aa].v][L];
	return Secret(arr1[vv[aa].v][L], arr2[vv[aa].v][R]);
}

Compilation message

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:31:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<range>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (i = 0; i < vv.size(); i++) {
      |              ~~^~~~~~~~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:49:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<range>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for (i = 0; i < vv.size(); i++) {
      |              ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 134 ms 6764 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 587620235.
2 Incorrect 142 ms 6508 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 238129576.
3 Incorrect 146 ms 6508 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 564439328.
4 Incorrect 500 ms 12396 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 846921768.
5 Incorrect 510 ms 12396 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 774413328.
6 Incorrect 502 ms 12268 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 816464713.
7 Incorrect 547 ms 12268 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 606644347.
8 Incorrect 522 ms 12396 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 32631240.
9 Incorrect 517 ms 12396 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 143002021.
10 Incorrect 503 ms 12396 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 539282251.