# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
52477 |
2018-06-26T05:30:03 Z |
노영훈(#1364) |
비밀 (JOI14_secret) |
C++11 |
|
665 ms |
16444 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int MX=1001;
int n, A[MX];
vector<int> P;
// p <= x < q, p < y <= q
int D[MX][MX]; // [x, y)
int E[MX][MX]; // [x, q)
int F[MX][MX]; // [p, y)
void filld(){
for(int i=0; i<(int)P.size()-1; i++){
int p=P[i], q=P[i+1];
for(int x=p; x<q; x++){
D[x][x+1]=A[x];
for(int y=x+2; y<=q; y++)
D[x][y]=Secret(D[x][y-1], A[y]);
}
}
/*
for(int i=0; i<n; i++){
D[i][i+1]=A[i];
for(int j=i+2; j<n; j++){
D[i][j]=Secret(D[i][j-1], A[j]);
}
}
*/
}
void fille(){
for(int i=1; i<(int)P.size(); i++){
int p=P[i-1], q=P[i];
E[q-1][q]=A[q-1];
for(int x=q-2; x>=p; x--){
E[x][q]=Secret(A[x], E[x+1][q]);
}
}
for(int i=0; i<(int)P.size(); i+=2){
int q=P[i];
E[q-1][q]=A[q-1];
for(int x=q-2; x>=0; x--){
E[x][q]=Secret(A[x], E[x+1][q]);
}
if(q>n/2) break;
}
}
void fillf(){
for(int i=0; i<(int)P.size()-1; i++){
int p=P[i], q=P[i+1];
F[p][p+1]=A[p];
for(int y=p+2; y<=q; y++)
F[p][y]=Secret(F[p][y-1], A[y]);
}
for(int i=(int)P.size()-1; i>=0; i-=2){
int p=P[i];
F[p][p+1]=A[p];
for(int y=p+2; y<n; y++)
F[p][y]=Secret(F[p][y-1], A[y]);
if(p<=n/2) break;
}
}
void Init(int N, int _A[]) {
n=N;
for(int i=0; i<n; i++) A[i]=_A[i];
for(int p=0; p<n; p+=32) P.push_back(p);
if(n%32!=0) P.push_back(n);
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
D[i][j]=E[i][j]=F[i][j]=-1;
filld();
fille();
fillf();
}
int Query(int L, int R) {
int l=L, r=R+1;
for(int p:P){
// [l, p), [p, r)
if(l<p && p<r && E[l][p]>=0 && F[p][r]>=0)
return Secret(E[l][p], F[p][r]);
}
return D[l][r];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
203 ms |
8440 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 860882111. |
2 |
Incorrect |
164 ms |
8488 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : -1. |
3 |
Incorrect |
177 ms |
8540 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 203716622. |
4 |
Incorrect |
600 ms |
16188 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 108118079. |
5 |
Incorrect |
608 ms |
16340 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : -1. |
6 |
Incorrect |
611 ms |
16384 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 587420923. |
7 |
Incorrect |
616 ms |
16384 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 41139235. |
8 |
Incorrect |
598 ms |
16444 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 427867224. |
9 |
Incorrect |
592 ms |
16444 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 30933098. |
10 |
Incorrect |
665 ms |
16444 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 610583041. |