Submission #960942

# Submission time Handle Problem Language Result Execution time Memory
960942 2024-04-11T09:31:14 Z pcc Secret (JOI14_secret) C++17
6 / 100
382 ms 4864 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

const int mxn = 1010;
vector<int> pref[mxn*4],suf[mxn*4];
int arr[mxn];
int N;

#define mid ((l+r)>>1)
#define ls now*2+1
#define rs now*2+2
void build(int now,int l,int r){
	if(l == r){
		pref[now].push_back(arr[l]);
		suf[now].push_back(arr[l]);
		return;
	}
	build(ls,l,mid);
	build(rs,mid+1,r);
	pref[now] = pref[ls];
	for(int i = mid+1;i<=r;i++)pref[now].push_back(Secret(pref[now].back(),arr[i]));
	suf[now] = suf[rs];
	reverse(suf[now].begin(),suf[now].end());
	for(int i = mid;i>=l;i--)suf[now].push_back(Secret(arr[i],suf[now].back()));
	reverse(suf[now].begin(),suf[now].end());
	//cout<<l<<' '<<r<<":";cout<<endl;for(auto &i:pref[now])cout<<i<<',';cout<<endl;for(auto &i:suf[now])cout<<i<<',';cout<<endl;
	return;
}

int getval(int now,int l,int r,int s,int e){
	if(l == r)return arr[l];
	if(mid>=s&&mid<e){
		return Secret(suf[ls].end()[s-mid-1],pref[rs][e-mid-1]);
	}
	if(mid>=e)return getval(ls,l,mid,s,e);
	else return getval(rs,mid+1,r,s,e);
}
#undef ls
#undef rs
#undef mid

void Init(int NN, int A[]) {
	N = NN;
	for(int i = 0;i<N;i++)arr[i] = A[i];
	build(0,0,N-1);
	return;
}


int Query(int L, int R) {
	return getval(0,0,N-1,L,R);
}
# Verdict Execution time Memory Grader output
1 Correct 116 ms 3024 KB Output is correct - number of calls to Secret by Init = 4598, maximum number of calls to Secret by Query = 1
2 Correct 103 ms 3012 KB Output is correct - number of calls to Secret by Init = 4608, maximum number of calls to Secret by Query = 1
3 Correct 104 ms 3100 KB Output is correct - number of calls to Secret by Init = 4619, maximum number of calls to Secret by Query = 1
4 Partially correct 373 ms 4864 KB Output isn't correct - number of calls to Secret by Init = 9965, maximum number of calls to Secret by Query = 1
5 Partially correct 370 ms 4692 KB Output isn't correct - number of calls to Secret by Init = 9976, maximum number of calls to Secret by Query = 1
6 Partially correct 375 ms 4800 KB Output isn't correct - number of calls to Secret by Init = 9976, maximum number of calls to Secret by Query = 1
7 Partially correct 368 ms 4800 KB Output isn't correct - number of calls to Secret by Init = 9976, maximum number of calls to Secret by Query = 1
8 Partially correct 372 ms 4796 KB Output isn't correct - number of calls to Secret by Init = 9976, maximum number of calls to Secret by Query = 1
9 Partially correct 382 ms 4792 KB Output isn't correct - number of calls to Secret by Init = 9976, maximum number of calls to Secret by Query = 1
10 Partially correct 370 ms 4736 KB Output isn't correct - number of calls to Secret by Init = 9976, maximum number of calls to Secret by Query = 1