답안 #548160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548160 2022-04-12T15:27:10 Z Alex_tz307 비밀 (JOI14_secret) C++17
0 / 100
447 ms 4468 KB
#include <bits/stdc++.h>
#include "secret.h"
 
using namespace std;
 
const int kN = 1e3;
const int kLog = 16;
int n, a[kN], dp[kN][kLog];
 
void solve(int l, int r, int level) {
  if (l == r) {
    return;
  }
  int mid = (l + r) / 2;
  dp[mid][level] = a[mid];
  dp[mid + 1][level] = a[mid + 1];
  for (int i = mid - 1; i >= l; --i) {
    dp[i][level] = Secret(dp[i + 1][level], a[i]);
  }
  for (int i = mid + 2; i <= r; ++i) {
    dp[i][level] = Secret(dp[i - 1][level], a[i]);
  }
  solve(l, mid, level + 1);
  solve(mid + 1, r, level + 1);
}
 
void Init(int N, int A[]) {
  n = N;
  for (int i = 0; i < n; ++i) {
    a[i] = A[i];
  }
  solve(0, n - 1, 0);
}
 
int Query(int l, int r) {
  if (l == r) {
    return a[l];
  }
  int st = 0, dr = n - 1, level = 0;
  while (st <= dr) {
    int mid = (st + dr) / 2;
    if (l <= mid && mid < r) {
      return Secret(dp[l][level], dp[r][level]);
    }
    if (mid < l) {
      st = mid + 1;
    } else {
      dr = mid;
    }
    level += 1;
  }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 118 ms 2508 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 122 ms 2424 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 118 ms 2348 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 447 ms 4260 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 435 ms 4244 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 440 ms 4432 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 444 ms 4300 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 441 ms 4468 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 440 ms 4272 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 442 ms 4376 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.