답안 #747861

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747861 2023-05-24T23:49:42 Z Markomafko972 비밀 (JOI14_secret) C++14
0 / 100
662 ms 524288 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 kol = 0;
 
// 4: 0 1 2 3 
 
void rek(int l, int r) {
	if (l+1 == r) {
		val[l][l] = a[l];
		return;
	}
	
	int mid = (l+r-1)/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++;
		if (tren > 1e9) assert(0);
		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++;
		if (tren > 1e9) assert(0);
		val[mid][j] = tren;
	}
 
	rek(l, mid);
	rek(mid, r);
}
 
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);
}
 
int Query(int l, int r) {
	if (l == r) return a[l];
	for (int i = l; i < r; i++) {
		if (val[l][i] != -1 && val[i+1][r] != -1) return Secret(val[l][i], val[i+1][r]);
	}
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 358 ms 524288 KB Execution killed with signal 9
2 Runtime error 396 ms 524288 KB Execution killed with signal 9
3 Runtime error 339 ms 524288 KB Execution killed with signal 9
4 Runtime error 647 ms 524288 KB Execution killed with signal 9
5 Runtime error 656 ms 524288 KB Execution killed with signal 9
6 Runtime error 644 ms 524288 KB Execution killed with signal 9
7 Runtime error 657 ms 524288 KB Execution killed with signal 9
8 Runtime error 646 ms 524288 KB Execution killed with signal 9
9 Runtime error 662 ms 524288 KB Execution killed with signal 9
10 Runtime error 659 ms 524288 KB Execution killed with signal 9