Submission #751913

# Submission time Handle Problem Language Result Execution time Memory
751913 2023-06-01T19:30:18 Z Markomafko972 Secret (JOI14_secret) C++17
100 / 100
482 ms 12144 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;

int val[1005][1005];
int sus[1005][1005];

void rek(int l, int r) {
	if (l >= r) return;
	
	int mid = (l+r)/2;
	for (int i = l; i <= mid; i++) {
		for (int j = mid+1; j <= r; j++) sus[i][j] = mid;
	}
	
	for (int j = mid+2; j <= r; j++) val[mid+1][j] = Secret(val[mid+1][j-1], val[j][j]);
	for (int j = mid-1; j >= l; j--) val[j][mid] = Secret(val[j][j], val[j+1][mid]);
 
	rek(l, mid);
	rek(mid+1, r);
}
 
void Init(int N, int A[]) {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) val[i][j] = A[i];
			else val[i][j] = -1;
		}
	}
	
	rek(0, N-1);
}
 
int Query(int L, int R) {
	if (val[L][R] != -1) return val[L][R];
	return Secret(val[L][sus[L][R]], val[sus[L][R]+1][R]);
}
# Verdict Execution time Memory Grader output
1 Correct 125 ms 6388 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 137 ms 6408 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 123 ms 6324 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 433 ms 12140 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 482 ms 12100 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 462 ms 12084 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 469 ms 12084 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 467 ms 12144 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 448 ms 12124 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 443 ms 12116 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1