Submission #930633

# Submission time Handle Problem Language Result Execution time Memory
930633 2024-02-20T08:35:54 Z oblantis Secret (JOI14_secret) C++17
100 / 100
466 ms 4908 KB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include "secret.h";
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e6 + 1;
//int secret_count;
map<pii, int> sh;
//int Secret(int X, int Y) {
  //++secret_count;
  //return (X + 2 * (Y / 2));
//}
void go(int l, int r){
	if(l + 1 >= r)return;
	int mid = l + (r - l) / 2;
	for(int i = mid - 2; i >= l; i--){
		sh[{i, mid - 1}] = Secret(sh[{i, i}], sh[{i + 1, mid - 1}]);
	}
	for(int i = mid + 1; i < r; i++){
		sh[{mid, i}] = Secret(sh[{mid, i - 1}], sh[{i, i}]);
	}
	go(l, mid);
	go(mid, r);
}
void Init(int n, int a[]) {
	for(int i = 0; i < n; i++){
		sh[{i, i}] = a[i];
	}
	go(0, n);
}
int Query(int l, int r) {
	if(sh.find({l, r}) != sh.end())return sh[{l, r}];
	for(int j = l; j < r; j++){
		if(sh.find({l, j}) != sh.end() && sh.find({j + 1, r}) != sh.end()){
			return Secret(sh[{l, j}], sh[{j + 1, r}]);
		}
	}
	return 0;
}
//int main(){
	//int n;
	//cin >> n;
	//int a[n];
	//for(int i = 0; i < n; i++){
		//cin >> a[i];
	//}
	//Init(n, a);
	//int q;
	//cin >> q;
	//while(q--){
		//int l, r;
		//cin >> l >> r;
		//cout << Query(l, r) << '\n';
	//}
	//return 0;
//}

Compilation message

secret.cpp:3:20: warning: extra tokens at end of #include directive
    3 | #include "secret.h";
      |                    ^
# Verdict Execution time Memory Grader output
1 Correct 128 ms 2724 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 133 ms 2716 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 128 ms 2832 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 434 ms 4764 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 407 ms 4768 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 389 ms 4688 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 454 ms 4904 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 461 ms 4684 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 454 ms 4688 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 466 ms 4908 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1