답안 #747213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747213 2023-05-23T23:55:56 Z Markomafko972 비밀 (JOI14_secret) C++14
0 / 100
444 ms 8348 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;
int kol = 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--) {
		if (kol == 8000) assert(0);
		tren = Secret(tren, a[j]);
		kol++;
		val[j][mid-1] = tren;
	}
	tren = a[mid];
	for (int j = mid+1; j < r; j++) {
		if (kol == 8000) assert(0);
		tren = Secret(tren, a[j]);
		kol++;
		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;
	memset(val, -1, sizeof val);
	for (int i = 0; i < n; i++) {
		a[i] = A[i];
		val[i][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) {
				if (val[v[i][j]][r] == -1 || (l <= v[i][j]-1 && val[l][v[i][j]-1] == -1)) assert(0);
				
				return 0;
				
				if (l <= v[i][j]-1) return Secret(val[l][v[i][j]-1], val[v[i][j]][r]);
				else return val[v[i][j]][r];
			}
		}
	}
	return -1;
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:55:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   for (int j = 0; j < v[i].size(); j++) {
      |                   ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 117 ms 6300 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 0.
2 Incorrect 118 ms 6272 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 0.
3 Incorrect 121 ms 6328 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 0.
4 Incorrect 432 ms 8152 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 0.
5 Incorrect 440 ms 8308 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 0.
6 Incorrect 443 ms 8268 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 0.
7 Incorrect 444 ms 8308 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 0.
8 Incorrect 437 ms 8348 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 0.
9 Incorrect 419 ms 8208 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 0.
10 Incorrect 439 ms 8268 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 0.