답안 #125933

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125933 2019-07-06T14:26:10 Z AlexLuchianov 비밀 (JOI14_secret) C++14
0 / 100
990 ms 524292 KB
#include <secret.h>

int const nmax = 1000;

//int Secret(int X, int Y)

int dp[1 + nmax][1 + nmax];
int v[1 + nmax];

void compute(int from, int to){
  int mid = (from + to) / 2;
  compute(from, mid);
  compute(mid + 1, to);
  for(int i = mid - 1; from <= i; i--){
    if(dp[i][mid] == -1)
      dp[i][mid] = Secret(v[i], dp[i + 1][mid]);
  }
  for(int i = mid + 2; i <= to; i++)
    if(dp[mid + 1][i] == -1)
      dp[mid + 1][i] = Secret(dp[mid + 1][i - 1], v[i]);
}
int n;

void Init(int N, int A[]){
  n = N;
  for(int i = 0; i < n; i++)
    v[i] = A[i];

  for(int i = 0;i < N; i++)
    for(int j = i; j < N; j++)
      dp[i][j] = -1;
  for(int i = 0; i < n; i++)
    dp[i][i] = v[i];
  compute(0, N - 1);
}

int ask(int from, int to, int x, int y){
  int mid = (from + to)/ 2;
  if(x <= mid && mid + 1 <= y)
    return Secret(dp[x][mid], dp[mid + 1][y]);
  else {
    if(y <= mid)
      return ask(from, mid, x, y);
    else
      return ask(mid + 1, to, x, y);
  }
}

int Query(int L, int R) {
  return ask(0, n - 1, L, R);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 576 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 571 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 572 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 986 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 990 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 982 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 980 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 978 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 981 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 985 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)