Submission #747208

#TimeUsernameProblemLanguageResultExecution timeMemory
747208Markomafko972Secret (JOI14_secret)C++14
0 / 100
460 ms8240 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; int kol = 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--) { if (kol == 8000) assert(0); tren = Secret(tren, a[j]); kol++; val[j][mid-1] = tren; } tren = a[mid]; for (int j = mid+1; j < r; j++) { if (kol == 8000) assert(0); tren = Secret(tren, a[j]); kol++; 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]; val[i][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) { if (l <= v[i][j]-1) return Secret(val[l][v[i][j]-1], val[v[i][j]][r]); else return val[v[i][j]][r]; } } } return -1; }

Compilation message (stderr)

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