Submission #749048

# Submission time Handle Problem Language Result Execution time Memory
749048 2023-05-27T09:31:21 Z mariowong Secret (JOI14_secret) C++14
0 / 100
452 ms 4740 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
map <pair<int,int>,pair<int,bool>  > m;
/*int Secret(int X,int Y){
	return min(X+2*(Y/2),1000000000);
}*/
int a[1005];
void ask(int l,int r){
	int mid=(l+r)/2;
	if (l != r){
		ask(l,mid);
		ask(mid+1,r);
	} 
	int val=a[r];
	for (int i=r-1;i>=l;i--){
		if (!m[{i,r}].second){
			val=Secret(a[i],val);
			m[{i,r}]={val,true};
		} 
		else
		val=m[{i,r}].first;
	}
}
void Init(int N, int A[]) {
  	m.clear();
  	int mid=(N-1)/2;	
  	for (int i=0;i<N;i++) a[i]=A[i];
  	for (int i=0;i<N;i++) m[{i,i}]={a[i],true};
	ask(0,mid);
	ask(mid+1,N-1);
}
 
int Query(int L, int R) {
	if (m[{L,R}].second) return m[{L,R}].first;
	for (int i=L;i<R;i++){
		if (m[{L,i}].second && m[{i+1,R}].second) return Secret(m[{L,i}].first,m[{i+1,R}].first);
	}
  return 1000;
}
/*
int a[105];
int main(){
	int n;
	cin >> n;
	for (int i=0;i<n;i++) cin >> a[i];
	Init(n,a);
	int q;
	cin >> q;
	for (int i=1;i<=q;i++){
		int u,v;
		cin >> u >> v;
		cout << Query(u,v) << "\n";
	}
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 2508 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 1000.
2 Incorrect 114 ms 2508 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 1000.
3 Incorrect 113 ms 2448 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 1000.
4 Incorrect 425 ms 4532 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 1000.
5 Incorrect 452 ms 4532 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 1000.
6 Incorrect 422 ms 4568 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 1000.
7 Incorrect 436 ms 4584 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 1000.
8 Incorrect 422 ms 4672 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 1000.
9 Incorrect 419 ms 4648 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 1000.
10 Incorrect 428 ms 4740 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 1000.