# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
366266 | rocks03 | Secret (JOI14_secret) | C++14 | 521 ms | 5164 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define Re(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
map<pii, int> memo;
int Secret(int x, int y);
int queries = 0;
const int MAXQ = 8000;
int ask(int x, int y){
if(memo.count({x, y}))
return memo[{x, y}];
queries++;
if(queries > MAXQ) return 0;
memo[{x, y}] = Secret(x, y);
return memo[{x, y}];
}
const int MAXK = 10;
const int MAXN = 1e3;
int *a, st[MAXK][MAXN];
void Init(int N, int A[]){
a = A;
rep(i, 0, N){
st[0][i] = a[i];
}
rep(k, 0, MAXK - 1){
rep(i, 0, N + 1 - (1 << (k + 1))){
st[k + 1][i] = ask(st[k][i], st[k][i + (1 << k)]);
}
}
}
int Query(int L, int R){
int ans = INT_MAX;
Re(k, MAXK - 1, 0){
if((R - L + 1) >> k & 1){
if(ans == INT_MAX) ans = st[k][L];
else ans = ask(ans, st[k][L]);
L += (1 << k);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |