Submission #381640

#TimeUsernameProblemLanguageResultExecution timeMemory
381640flappybirdSecret (JOI14_secret)C++14
0 / 100
547 ms12396 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; typedef int ll; #define MAX 1010 struct range { ll x, y; ll v; }; vector<range> vv; vector<ll> a; ll arr1[MAX][MAX]; ll arr2[MAX][MAX]; void init(ll low, ll high) { if (low >= high) return; ll mid = (low + high) / 2; vv.push_back({ low, high, mid }); init(low, mid); init(mid + 1, high); } void Init(int N, int A[]) { init(1, N); ll i, j; ll mid; a.resize(N + 1); for (i = 0; i < N; i++) a[i + 1] = A[i]; for (i = 0; i < vv.size(); i++) { mid = vv[i].v; arr1[mid][mid] = A[mid - 1]; for (j = mid - 1; j >= vv[i].x; j--) arr1[mid][j] = Secret(A[j - 1], arr1[mid][j + 1]); if (mid + 1 <= vv[i].y) arr2[mid][mid + 1] = A[j + 1]; for (j = mid + 2; j <= vv[i].y; j++) arr2[mid][j] = Secret(arr2[mid][j - 1], A[j - 1]); } } int Query(int L, int R) { ll i; L++; R++; if (L == R) return a[L]; if (R - L == 1) return Secret(a[L], a[R]); ll m = 0; ll aa; aa = 0; for (i = 0; i < vv.size(); i++) { if (vv[i].x <= L && R <= vv[i].y) { if (m < vv[i].y - vv[i].x) { m = vv[i].y - vv[i].x; aa = i; } } } if (vv[aa].v == L) return Secret(a[L], arr2[vv[aa].v][R]); if (vv[aa].v == R) return arr1[vv[aa].v][L]; return Secret(arr1[vv[aa].v][L], arr2[vv[aa].v][R]); }

Compilation message (stderr)

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:31:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<range>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (i = 0; i < vv.size(); i++) {
      |              ~~^~~~~~~~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:49:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<range>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for (i = 0; i < vv.size(); i++) {
      |              ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...