Submission #217623

#TimeUsernameProblemLanguageResultExecution timeMemory
217623DodgeBallManSecret (JOI14_secret)C++14
100 / 100
545 ms8440 KiB
#include<bits/stdc++.h> #include "secret.h" #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 1e5 + 5, inf = 1e9; #define pb push_back #define mp make_pair #define ll long long #define ff first #define ss second #define all(a) a.begin(),a.end() #define sz(x) (int)x.size() typedef vector<int> vi; typedef pair<int,int> ii; typedef vector<ii> vii; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int ans[1005][1005]; void solve(int l, int r, int a[]){ if(l == r){ return; } int mid = (l + r) / 2; for(int i = mid - 1; i >= l; i--){ ans[i][mid] = Secret(a[i], ans[i + 1][mid]); } for(int i = mid + 2; i <= r; i++){ ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], a[i]); } solve(l, mid, a); solve(mid + 1, r, a); } void Init(int n, int a[]){ memset(ans, -1, sizeof ans); for(int i = 0; i < n; i++)ans[i][i] = a[i]; solve(0, n - 1, a); } int Query(int ql, int qr){ if(ans[ql][qr] != -1)return ans[ql][qr]; for(int i = ql; i < qr; i++){ if(ans[ql][i] != -1 && ans[i + 1][qr] != -1){ return Secret(ans[ql][i], ans[i + 1][qr]); } } }

Compilation message (stderr)

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