답안 #227132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227132 2020-04-26T07:36:27 Z arnold518 비밀 (JOI14_secret) C++14
0 / 100
517 ms 4680 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1000;

int N, A[MAXN+10];
int tree[MAXN+10][30];

void init(int node, int tl, int tr, int dep)
{
	int i, j;

	int mid=tl+tr>>1;
	tree[mid][dep]=A[mid];
	for(i=mid-1; i>=tl; i--) tree[i][dep]=Secret(A[i], tree[i+1][dep]);

	tree[mid+1][dep]=A[mid+1];
	for(i=mid+2; i<=tr; i++) tree[i][dep]=Secret(tree[i-1][dep], A[i]);

	if(tl==tr) return;
	init(node*2, tl, mid, dep+1);
	init(node*2+1, mid+1, tr, dep+1);
}

int query(int node, int tl, int tr, int l, int r, int dep)
{
	int mid=tl+tr>>1;
	if(tl<=l && r<=tr) return Secret(tree[l][dep], tree[r][dep]);
	if(r<=mid) return query(node*2, tl, mid, l, r, dep+1);
	if(mid+1<=l) return query(node*2+1, mid+1, tr, l, r, dep+1);
}

void Init(int _N, int _A[])
{
	int i, j;
	N=_N;
	for(i=1; i<=N; i++) A[i]=_A[i-1];
	init(1, 1, N, 1);
}

int Query(int L, int R)
{
	L++; R++;
	if(L==R) return A[L];
	return query(1, 1, N, L, R, 1);
}

Compilation message

secret.cpp: In function 'void init(int, int, int, int)':
secret.cpp:18:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=tl+tr>>1;
          ~~^~~
secret.cpp:16:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
secret.cpp: In function 'int query(int, int, int, int, int, int)':
secret.cpp:32:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=tl+tr>>1;
          ~~^~~
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:40:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
secret.cpp: In function 'int query(int, int, int, int, int, int)':
secret.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 137 ms 2424 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 574960662.
2 Incorrect 138 ms 2552 KB Wrong Answer: Query(102, 157) - expected : 32612619, actual : 697381057.
3 Incorrect 138 ms 2552 KB Wrong Answer: Query(334, 369) - expected : 363022362, actual : 8613892.
4 Incorrect 502 ms 4680 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 274825282.
5 Incorrect 501 ms 4556 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 307380480.
6 Incorrect 505 ms 4600 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 950550627.
7 Correct 514 ms 4600 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 517 ms 4472 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 510 ms 4472 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 512 ms 4472 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1