답안 #381642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381642 2021-03-25T12:14:34 Z flappybird 비밀 (JOI14_secret) C++14
0 / 100
529 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[mid];
		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 133 ms 6508 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 587620235.
2 Incorrect 144 ms 6508 KB Wrong Answer: Query(102, 157) - expected : 32612619, actual : 962726377.
3 Incorrect 138 ms 6508 KB Wrong Answer: Query(334, 369) - expected : 363022362, actual : 547672410.
4 Incorrect 500 ms 12268 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 846921768.
5 Incorrect 515 ms 12296 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 212882718.
6 Incorrect 505 ms 12256 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 423176097.
7 Correct 523 ms 12268 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 529 ms 12396 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 520 ms 12284 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 521 ms 12268 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1