Submission #747135

#TimeUsernameProblemLanguageResultExecution timeMemory
747135Markomafko972Secret (JOI14_secret)C++14
0 / 100
501 ms16652 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; int n; int a[1005]; int val[1005][1005]; vector<int> v[1005]; int maxid = 0; // 4: 0 1 2 3 void rek(int l, int r, int d) { maxid = max(maxid, d); if (l+1 == r) { v[d].push_back(l); val[l][l] = a[l]; return; } int mid = (l+r)/2; int tren = a[mid-1]; for (int j = mid-2; j >= l; j--) { tren = Secret(tren, a[j]); val[j][mid-1] = tren; } tren = a[mid]; for (int j = mid+1; j < r; j++) { tren = Secret(tren, a[j]); val[mid][j] = tren; } v[d].push_back(mid); rek(l, mid, d+1); rek(mid, r, d+1); } void Init(int N, int A[]) { n = N; for (int i = 0; i < n; i++) a[i] = A[i]; rek(0, n, 0); } int Query(int l, int r) { for (int i = 0; i <= maxid; i++) { for (int j = 0; j < v[i].size(); j++) { if (l <= v[i][j] && v[i][j] <= r) { return Secret(val[l][val[i][j]-1], val[v[i][j]][r]); } } } }

Compilation message (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (int j = 0; j < v[i].size(); j++) {
      |                   ~~^~~~~~~~~~~~~
secret.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...