# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
52473 |
2018-06-26T05:14:52 Z |
김세빈(#1365) |
비밀 (JOI14_secret) |
C++11 |
|
641 ms |
4784 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> V[3030];
int S[3030];
int sz;
void Init(int N, int A[])
{
int i,k,t;
for(sz=1;sz<N;sz<<=1);
for(i=0;i<N;i++) S[sz+i] = A[i];
for(;i<sz;i++) S[sz+i] = -1;
for(i=sz-1;i;i--){
if(S[i<<1|1] == -1) S[i] = -1;
else S[i] = Secret(S[i<<1], S[i<<1|1]);
}
for(i=1;i<sz+N;i++){
if(~i & 1) continue;
t = S[i];
V[i].push_back(t);
if(!(i & i+1)) continue;
for(k=i+1>>1;;){
if(S[k] == -1) break;
if(!(k & k+1)) break;
if(k & 1){
t = Secret(t, S[k]);
V[i].push_back(t);
}
k = k+1 >> 1;
}
}
for(i=1;i<sz+N;i++){
if(i & 1) continue;
t = S[i];
V[i].push_back(t);
if(!(i & i-1)) continue;
for(k=i-1>>1;;){
if(S[k] == -1) break;
if(!(k & k-1)) break;
if(~k & 1){
t = Secret(S[k], t);
V[i].push_back(t);
}
k = k-1 >> 1;
}
}
}
int Query(int L, int R)
{
int f1, f2, cnt1, cnt2;
f1 = f2 = -1;
cnt1 = cnt2 = 0;
L += sz, R += sz;
for(;L<R;){
if(L & 1){
if(f1 == -1) f1 = L;
else cnt1 ++;
}
if(~R & 1){
if(f2 == -1) f2 = R;
else cnt2 ++;
}
L = L+1 >> 1;
R = R-1 >> 1;
}
if(L == R){
if(f1 == -1 && f2 == -1) return S[L];
else if(f1 == -1) return Secret(S[L], V[f2][cnt2]);
else if(f2 == -1) return Secret(V[f1][cnt1], S[R]);
return Secret(V[f1][cnt1+1], V[f2][cnt2]);
}
return Secret(V[f1][cnt1], V[f2][cnt2]);;
}
Compilation message
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:31:13: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
if(!(i & i+1)) continue;
~^~
secret.cpp:33:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(k=i+1>>1;;){
~^~
secret.cpp:36:14: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
if(!(k & k+1)) break;
~^~
secret.cpp:43:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
k = k+1 >> 1;
~^~
secret.cpp:53:13: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
if(!(i & i-1)) continue;
~^~
secret.cpp:55:10: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
for(k=i-1>>1;;){
~^~
secret.cpp:58:14: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
if(!(k & k-1)) break;
~^~
secret.cpp:65:9: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
k = k-1 >> 1;
~^~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:89:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
L = L+1 >> 1;
~^~
secret.cpp:90:8: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
R = R-1 >> 1;
~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
166 ms |
2516 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809837279. |
2 |
Incorrect |
160 ms |
2680 KB |
Wrong Answer: Query(214, 350) - expected : 750452896, actual : 583252008. |
3 |
Incorrect |
159 ms |
2776 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 67264574. |
4 |
Incorrect |
596 ms |
4572 KB |
Wrong Answer [1] |
5 |
Incorrect |
583 ms |
4660 KB |
Wrong Answer [1] |
6 |
Incorrect |
583 ms |
4712 KB |
Wrong Answer [1] |
7 |
Incorrect |
585 ms |
4712 KB |
Wrong Answer [1] |
8 |
Incorrect |
641 ms |
4764 KB |
Wrong Answer [1] |
9 |
Incorrect |
584 ms |
4784 KB |
Wrong Answer [1] |
10 |
Incorrect |
597 ms |
4784 KB |
Wrong Answer [1] |