답안 #657768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657768 2022-11-11T01:59:48 Z hollwo_pelw 비밀 (JOI14_secret) C++17
컴파일 오류
0 ms 0 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

// Secret(int x, int y);

int calc[1 << 10][1 << 10];

void Init(int N, int A[]) {
	memset(calc, -1, calc);
	for (int i = 0; i < N; i++)
		calc[i][i] = A[i];
	for (int i = 10; i; i --) {
		for (int L = 0; L < N; L += 1 << i) {
			int M = min(N, L + (1 << (i - 1)));
			int R = min(N - 1, L + (1 << i));
			for (int j = M + 1; j <= R; j++)
				calc[M][j] = Secret(calc[M][j - 1], A[j]);
			for (int j = M - 2; j >= L; j--)
				calc[j][M - 1] = Secret(calc[j + 1][M - 1], A[j]);
		}
	}
}

int Query(int L, int R) {
	if (calc[L][R] >= 0)
		return calc[L][R];
	for (int M = L; M < R; M++) {
		if (calc[L][M] >= 0 && calc[M + 1][R] >= 0)
			return Secret(calc[L][M], calc[M + 1][R]);
	}
}

Compilation message

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:10:19: error: invalid conversion from 'int (*)[1024]' to 'size_t' {aka 'long unsigned int'} [-fpermissive]
   10 |  memset(calc, -1, calc);
      |                   ^~~~
      |                   |
      |                   int (*)[1024]
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from secret.cpp:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 3 of 'void* memset(void*, int, size_t)'
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
   32 | }
      | ^