답안 #747135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747135 2023-05-23T16:40:21 Z Markomafko972 비밀 (JOI14_secret) C++14
0 / 100
501 ms 16652 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

int n;
int a[1005];
int val[1005][1005];
vector<int> v[1005];
int maxid = 0;

// 4: 0 1 2 3 

void rek(int l, int r, int d) {
	maxid = max(maxid, d);
	if (l+1 == r) {
		v[d].push_back(l);
		val[l][l] = a[l];
		return;
	}
	
	int mid = (l+r)/2;
	int tren = a[mid-1];
	for (int j = mid-2; j >= l; j--) {
		tren = Secret(tren, a[j]);
		val[j][mid-1] = tren;
	}
	tren = a[mid];
	for (int j = mid+1; j < r; j++) {
		tren = Secret(tren, a[j]);
		val[mid][j] = tren;
	}
	v[d].push_back(mid);

	rek(l, mid, d+1);
	rek(mid, r, d+1);
}

void Init(int N, int A[]) {
	n = N;
	for (int i = 0; i < n; i++) a[i] = A[i];
	rek(0, n, 0);
}

int Query(int l, int r) {
	for (int i = 0; i <= maxid; i++) {
		for (int j = 0; j < v[i].size(); j++) {
			if (l <= v[i][j] && v[i][j] <= r) {
				return Secret(val[l][val[i][j]-1], val[v[i][j]][r]);
			}
		}
	}
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (int j = 0; j < v[i].size(); j++) {
      |                   ~~^~~~~~~~~~~~~
secret.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 122 ms 8796 KB Execution killed with signal 11
2 Runtime error 126 ms 8800 KB Execution killed with signal 11
3 Runtime error 127 ms 8960 KB Execution killed with signal 11
4 Incorrect 440 ms 8332 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 611025428.
5 Runtime error 472 ms 16652 KB Execution killed with signal 11
6 Incorrect 472 ms 8332 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 278446241.
7 Runtime error 501 ms 16640 KB Execution killed with signal 11
8 Runtime error 475 ms 16628 KB Execution killed with signal 11
9 Runtime error 467 ms 16596 KB Execution killed with signal 11
10 Runtime error 488 ms 16536 KB Execution killed with signal 11