# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52501 |
2018-06-26T06:09:51 Z |
노영훈(#1364) |
Secret (JOI14_secret) |
C++11 |
|
641 ms |
16468 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-1]);
}
}
/*
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-1]);
}
}
cout<<"\nD: \n";
for(int i=0; i<n; i++){
for(int j=1; j<=n; j++){
cout<<D[i][j]<<' ';
}
cout<<'\n';
}
*/
}
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=1; 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(n/2<=q) break;
}
/*
cout<<"\nE: \n";
for(int i=0; i<n; i++){
for(int j=1; j<=n; j++){
cout<<E[i][j]<<' ';
}
cout<<'\n';
}
*/
}
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-1]);
}
for(int i=(int)P.size()-((int)P.size()%2==1 ? 2 : 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-1]);
if(p<n/2) break;
}
/*
cout<<"\nF: \n";
for(int i=0; i<n; i++){
for(int j=1; j<=n; j++){
cout<<F[i][j]<<' ';
}
cout<<'\n';
}
*/
}
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);
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;
// printf("SOLVING %d %d\n", l, r);
for(int p:P){
if(!(l<p && p<r)) continue;
// printf("IS %d VALID?\n", p);
// [l, p), [p, r)
if(E[l][p]>=0 && F[p][r]>=0)
return Secret(E[l][p], F[p][r]);
if(D[l][p]>=0 && D[p][r]>=0)
return Secret(D[l][p], D[p][r]);
}
return D[l][r];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
163 ms |
8568 KB |
Wrong Answer: Query(113, 206) - expected : 536899947, actual : -1. |
2 |
Incorrect |
166 ms |
8568 KB |
Wrong Answer: Query(30, 75) - expected : 635142465, actual : -1. |
3 |
Incorrect |
165 ms |
8568 KB |
Wrong Answer: Query(290, 499) - expected : 92618778, actual : -1. |
4 |
Incorrect |
589 ms |
16204 KB |
Wrong Answer: Query(384, 458) - expected : 896057572, actual : -1. |
5 |
Incorrect |
622 ms |
16236 KB |
Wrong Answer: Query(626, 678) - expected : 512755800, actual : -1. |
6 |
Incorrect |
599 ms |
16460 KB |
Output isn't correct - number of calls to Secret by Init = 22290, maximum number of calls to Secret by Query = 1 |
7 |
Incorrect |
611 ms |
16460 KB |
Output isn't correct - number of calls to Secret by Init = 22290, maximum number of calls to Secret by Query = 1 |
8 |
Incorrect |
608 ms |
16460 KB |
Output isn't correct - number of calls to Secret by Init = 22290, maximum number of calls to Secret by Query = 1 |
9 |
Incorrect |
641 ms |
16460 KB |
Output isn't correct - number of calls to Secret by Init = 22290, maximum number of calls to Secret by Query = 1 |
10 |
Incorrect |
625 ms |
16468 KB |
Output isn't correct - number of calls to Secret by Init = 22290, maximum number of calls to Secret by Query = 1 |