답안 #915934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915934 2024-01-25T00:45:51 Z OAleksa 비밀 (JOI14_secret) C++14
100 / 100
400 ms 8440 KB
#include "secret.h"
#include <bits/stdc++.h>
//vaso daso gej
using namespace std;
#define f first
#define s second
const int N = 1010;
int n, a[N], val[N][N];
void solve(int L, int R) {
  if (R - L <= 1)
    return;
  int mid = (L + R) / 2;
  for (int i = mid - 1;i >= L;i--)
    val[i][mid] = Secret(a[i], val[i + 1][mid]);
  for (int i = mid + 2;i <= R;i++)
    val[mid + 1][i] = Secret(val[mid + 1][i - 1], a[i]);
  solve(L, mid);
  solve(mid + 1, R);
}
void Init(int N, int A[]) {
  n = N;
  for (int i = 0;i < n;i++) {
    a[i] = A[i];
    val[i][i] = a[i];
  }
  solve(0, n - 1);
}

int Query(int L, int R) {
  if (L == R)
    return a[L];
  else if (R == L + 1)
    return Secret(a[L], a[R]);
  for (int i = L;i <= R;i++) {
    for (int j = i + 1;j <= R;j++) {
      if (val[i][j - 1] > 0 && val[j][R])
        return Secret(val[i][j - 1], val[j][R]);
    }
  }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
   40 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 6992 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 110 ms 6824 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 112 ms 6740 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 386 ms 8372 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 383 ms 8276 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 393 ms 8364 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 383 ms 8440 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 395 ms 8272 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 387 ms 8364 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 400 ms 8356 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1