Submission #1092750

# Submission time Handle Problem Language Result Execution time Memory
1092750 2024-09-24T23:59:12 Z Saul0906 Secret (JOI14_secret) C++14
6 / 100
314 ms 4696 KB
#include "secret.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define rep(a,b,c) for(ll a=b; a<c; a++)
#define rep2(a,b,c,d) for(ll a=b; a<c; a+=d)
#define repr(a,b,c) for(ll a=b-1; a>c-1; a--)
#define repa(a,b) for(const auto &a: b)
#define multicase() int t; cin>>t; while(t--)
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define valid(c) cout<<(c ? "YES" : "NO")<<endl;
#define valid2(c,a,b) cout<<(c ? a : b)<<endl;
#define ll long long 
#define pq_min(a) priority_queue<a, vector<a>, greater<a>>
#define pq_max(a) priority_queue<a>
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mid ((l+r)>>1)
#define flush endl<<flush
#define vi vector<int>

using namespace std;

int n;
vi a;

struct segtree{
	segtree *left, *right;
	int l, r;
	vi p, s;
	segtree(){}
	segtree(int x, int y): l(x), r(y){
		if(l==r){
			p.pb(a[l]);
			s.pb(a[l]);
			return;
		}
		left = new segtree(l,mid);
		right = new segtree(mid+1,r);
		p.resize(r-l+1);
		s.resize(r-l+1);
		p[0]=left->p[0];
		s[0]=Secret(left->p.back(),right->p.back());
		s[r-l]=right->s.back();
		p[r-l]=s[0];
		rep(i,l+1,r){
			if(i>mid){
				p[i-l]=Secret(left->p.back(),right->p[i-mid-1]);
				s[i-l]=right->s[i-mid-1];
				
			}else{
				p[i-l]=left->p[i-l];
				s[i-l]=Secret(left->s[i-l],right->p.back());
			}
		}
	}
	int query(int x, int y){
		if(x==y) return a[x];
		if(y<l || r<x) return 0;
		if(x<=mid && y>mid){
			return Secret(left->s[x-l],right->p[y-mid-1]);
		}
		return left->query(x,y)+right->query(x,y);
	}
} st;

void Init(int N, int A[]) {
	a.resize(N);
	n=N;
	rep(i,0,n) a[i]=A[i];
	st = segtree(0,N-1);
}

int Query(int L, int R) {
	return st.query(L,R);
}
# Verdict Execution time Memory Grader output
1 Correct 85 ms 2640 KB Output is correct - number of calls to Secret by Init = 4088, maximum number of calls to Secret by Query = 1
2 Correct 85 ms 2644 KB Output is correct - number of calls to Secret by Init = 4097, maximum number of calls to Secret by Query = 1
3 Correct 84 ms 2640 KB Output is correct - number of calls to Secret by Init = 4107, maximum number of calls to Secret by Query = 1
4 Partially correct 304 ms 4692 KB Output isn't correct - number of calls to Secret by Init = 8967, maximum number of calls to Secret by Query = 1
5 Partially correct 307 ms 4688 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
6 Partially correct 306 ms 4692 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
7 Partially correct 305 ms 4696 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
8 Partially correct 309 ms 4692 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
9 Partially correct 314 ms 4692 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
10 Partially correct 311 ms 4692 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1