Submission #714063

# Submission time Handle Problem Language Result Execution time Memory
714063 2023-03-23T19:06:29 Z EthanKim8683 Secret (JOI14_secret) C++17
0 / 100
457 ms 8908 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;
    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){
  printf("%i\n",qry(l,r));
}

Compilation message

secret.cpp: In function 'I Query(I, I)':
secret.cpp:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
   48 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 116 ms 4760 KB Execution killed with signal 11
2 Runtime error 118 ms 4848 KB Execution killed with signal 11
3 Runtime error 125 ms 4824 KB Execution killed with signal 11
4 Runtime error 424 ms 8880 KB Execution killed with signal 11
5 Runtime error 449 ms 8808 KB Execution killed with signal 11
6 Runtime error 427 ms 8744 KB Execution killed with signal 11
7 Runtime error 421 ms 8680 KB Execution killed with signal 11
8 Runtime error 433 ms 8780 KB Execution killed with signal 11
9 Runtime error 431 ms 8908 KB Execution killed with signal 11
10 Runtime error 457 ms 8780 KB Execution killed with signal 11