# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
52474 |
2018-06-26T05:22:42 Z |
김세빈(#1365) |
비밀 (JOI14_secret) |
C++11 |
|
632 ms |
4840 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;
printf("%d %d\n",L,R);
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]);
else if(L & 1) return Secret(V[f1][cnt1+1], V[f2][cnt2]);
else return Secret(V[f1][cnt1], V[f2][cnt2+1]);
}
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:91:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
L = L+1 >> 1;
~^~
secret.cpp:92:8: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
R = R-1 >> 1;
~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
178 ms |
2552 KB |
Do not print anything to standard output |
2 |
Incorrect |
174 ms |
2660 KB |
Do not print anything to standard output |
3 |
Incorrect |
176 ms |
2712 KB |
Do not print anything to standard output |
4 |
Incorrect |
597 ms |
4616 KB |
Wrong Answer [1] |
5 |
Incorrect |
587 ms |
4728 KB |
Wrong Answer [1] |
6 |
Incorrect |
606 ms |
4728 KB |
Wrong Answer [1] |
7 |
Incorrect |
632 ms |
4728 KB |
Wrong Answer [1] |
8 |
Incorrect |
592 ms |
4772 KB |
Wrong Answer [1] |
9 |
Incorrect |
620 ms |
4808 KB |
Wrong Answer [1] |
10 |
Incorrect |
614 ms |
4840 KB |
Wrong Answer [1] |