# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
566046 | 2022-05-21T17:19:58 Z | SSRS | 비밀 (JOI14_secret) | C++14 | 466 ms | 8740 KB |
#include <bits/stdc++.h> #include "secret.h" using namespace std; template <typename T> struct disjoint_sparse_table{ function<T(T, T)> f; vector<T> A; vector<vector<T>> D; disjoint_sparse_table(){ } disjoint_sparse_table(vector<T> &A, function<T(T, T)> f): A(A), f(f){ int N = A.size(); int LOG = 32 - __builtin_clz(N - 1); D = vector<vector<T>>(LOG, vector<T>(N)); for (int i = 0; i < LOG; i++){ for (int j = 0; j < N; j += 1 << (i + 1)){ int d = 1 << i; D[i][j + d - 1] = A[j + d - 1]; for (int k = j + d - 2; k >= j; k--){ D[i][k] = f(A[k], D[i][k + 1]); } D[i][j + d] = A[j + d]; for (int k = j + d + 1; k < min(j + d * 2, N); k++){ D[i][k] = f(D[i][k - 1], A[k]); } } } } T query(int L, int R){ if (R - L == 1){ return A[L]; } else { R--; int b = 31 - __builtin_clz(R ^ L); return f(D[b][L], D[b][R]); } } }; disjoint_sparse_table<int> DST; void Init(int N, int A[]){ vector<int> A2(N); for (int i = 0; i < N; i++){ A2[i] = A[i]; } DST = disjoint_sparse_table<int>(A2, Secret); } int Query(int L, int R){ R++; return DST.query(L, R); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 122 ms | 2400 KB | Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 | Correct | 125 ms | 2432 KB | Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 | Runtime error | 126 ms | 4800 KB | Execution killed with signal 6 |
4 | Runtime error | 446 ms | 8672 KB | Execution killed with signal 6 |
5 | Runtime error | 447 ms | 8712 KB | Execution killed with signal 6 |
6 | Runtime error | 439 ms | 8608 KB | Execution killed with signal 6 |
7 | Runtime error | 466 ms | 8708 KB | Execution killed with signal 6 |
8 | Runtime error | 441 ms | 8740 KB | Execution killed with signal 6 |
9 | Runtime error | 444 ms | 8612 KB | Execution killed with signal 6 |
10 | Runtime error | 447 ms | 8664 KB | Execution killed with signal 6 |