Submission #714067

# Submission time Handle Problem Language Result Execution time Memory
714067 2023-03-23T19:30:17 Z EthanKim8683 Secret (JOI14_secret) C++17
0 / 100
461 ms 4468 KB
#include<bits/stdc++.h>
using namespace std;
using I=int;
const I N=1000;
#ifdef ETHANKIM8683
void Init(I,I[]);
I Query(I,I);
I Secret(I x,I y){
  return x+y;
}
I main(){
  I n,q;cin>>n>>q;
  I a_arr[n];
  for(I i=0;i<n;i++)cin>>a_arr[i];
  Init(n,a_arr);
  while(q--){
    I l,r;cin>>l>>r;
    printf("%i\n",Query(l-1,r-1));
  }
}
#else
#include"secret.h"
#endif
I*a_arr;
vector<I>vals[2*N];
I n;
void slv(I i=1,I l=0,I r=n-1){
  if(l>r)return;
  I m=l+(r-l)/2;
  vals[i].resize(r-l+1);
  if(m>=l)vals[i][m-l]=a_arr[m];
  if(m+1<=r)vals[i][m+1-l]=a_arr[m+1];
  for(I j=m;j-1>=l;j--)vals[i][j-1-l]=Secret(vals[i][j-l],a_arr[j-1]);
  for(I j=m+1;j+1<=r;j++)vals[i][j+1-l]=Secret(vals[i][j-l],a_arr[j+1]);
  slv(i<<1,l,m-1),slv(i<<1|1,m+1,r);
}
I qry(I l1,I r1,I i=1,I l2=0,I r2=n-1){
  I m=l2+(r2-l2)/2;
  if(r1<m)return qry(l1,r1,i<<1,l2,m-1);
  if(l1>m)return qry(l1,r1,i<<1|1,m+1,r2);
  return r1==m?vals[i][l1-l2]:Secret(vals[i][l1-l2],vals[i][r1-l2]);
}
void Init(I _n,I _a_arr[]){
  n=_n,a_arr=_a_arr,slv();
}
I Query(I l,I r){
  return qry(l,r);
}
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 2348 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 118 ms 2380 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 117 ms 2404 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 443 ms 4376 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 444 ms 4324 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 444 ms 4344 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 850129153.
7 Incorrect 453 ms 4388 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 443 ms 4356 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 442 ms 4468 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 461 ms 4332 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.