제출 #1125428

#제출 시각아이디문제언어결과실행 시간메모리
1125428KK_1729비밀 (JOI14_secret)C++17
100 / 100
449 ms8220 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; int prefix[1001][1001], n; vector<pair<int, int>> ranges; void populate(int L, int R, int A[]){ int mid = (L + R) / 2; prefix[mid][mid] = A[mid]; prefix[mid + 1][mid + 1] = A[mid + 1]; for (int i = mid + 2; i <= R; i++) prefix[mid + 1][i] = Secret(prefix[mid + 1][i - 1], A[i]); for (int i = mid - 1; i >= L; i--) prefix[mid][i] = Secret(A[i], prefix[mid][i + 1]); ranges.push_back({L, R}); if (L < mid) populate(L, mid, A); if (mid + 1 < R) populate(mid + 1, R, A); } void Init(int N, int A[]) { n = N; populate(0, N-1, A); } int Query(int L, int R) { // return 0; if (L == R) return prefix[L][L]; for (auto range: ranges){ int mid = (range.first+range.second)/2; if (L >= range.first && R <= range.second ){ if (mid == R) return prefix[mid][L]; if (L <= mid && R > mid){ return Secret(prefix[mid][L], prefix[mid+1][R]); } } } }

컴파일 시 표준 에러 (stderr) 메시지

secret.cpp: In function 'int Query(int, int)':
secret.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...