답안 #255878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255878 2020-08-02T03:27:11 Z IOrtroiii 비밀 (JOI14_secret) C++14
0 / 100
508 ms 8592 KB
#include "secret.h"

#include <bits/stdc++.h>

using namespace std;

int A[1010];
int dp[1010][1010];

void gen(int l, int r) {
   if (l == r) {
      dp[l][r] = A[l];
      return;
   }
   int md = (l + r) >> 1;
   gen(l, md);
   gen(md + 1, r);
   for (int i = md - 1; i >= l; --i) dp[i][md] = Secret(A[i], dp[i + 1][md]);
   for (int i = md + 2; i <= r; ++i) dp[i][md] = Secret(dp[md + 1][i - 1], A[i]);
}

void Init(int N, int _A[]) {
   for (int i = 0; i < N; ++i) A[i] = _A[i];
   memset(dp, -1, sizeof dp);
   gen(0, N - 1);
}

int Query(int l, int r) {
   if (l == r) return A[l];
   for (int md = l; md < r; ++md) {
      if (dp[l][md] >= 0 && dp[md + 1][r] >= 0) {
         return Secret(dp[l][md], dp[md + 1][r]);
      }
   }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 133 ms 6492 KB Wrong Answer [1]
2 Incorrect 131 ms 6520 KB Wrong Answer [1]
3 Incorrect 132 ms 6520 KB Wrong Answer [1]
4 Incorrect 484 ms 8568 KB Wrong Answer [1]
5 Incorrect 505 ms 8444 KB Wrong Answer [1]
6 Incorrect 508 ms 8380 KB Wrong Answer [1]
7 Incorrect 494 ms 8396 KB Wrong Answer [1]
8 Incorrect 487 ms 8440 KB Wrong Answer [1]
9 Incorrect 496 ms 8468 KB Wrong Answer [1]
10 Incorrect 492 ms 8592 KB Wrong Answer [1]