Submission #361896

# Submission time Handle Problem Language Result Execution time Memory
361896 2021-01-31T22:48:45 Z Lemur95 Secret (JOI14_secret) C++17
0 / 100
529 ms 8448 KB
#include <bits/stdc++.h>
#include "secret.h"
#pragma GCC optimize("Ofast")
#define x first
#define y second
#define ld long double
#define ll long long
#define ull unsigned long long
#define us unsigned short
#define lsb(x) ((x) & (-(x)))

using namespace std;

int n;

int v[1005], sum[1005][1005];

/*int Secret(int x, int y) {
  return x | y;
}*/

void divide(int st, int dr) {
  if(st == dr || st + 1 == dr) {
    //sum[st][st] = v[st];
    return;
  }
  int mid = (st + dr) >> 1;
  //sum[mid][mid] = v[mid];
  for(int i = mid - 1; i >= st; i--)
    sum[i][mid] = Secret(sum[i + 1][mid], v[i]);
  for(int i = mid + 2; i <= dr; i++)
    sum[mid + 1][i] = Secret(sum[mid + 1][i - 1], v[i]);
  divide(st, mid);
  divide(mid + 1, dr);
}

void Init(int N, int a[]) {
  n = N;
  for(int i = 0; i < n; i++)
    v[i] = a[i], sum[i][i] = a[i];
  divide(0, n - 1);
}

int solve(int st, int dr, int l, int r) {
  int mid = (st + dr) >> 1;
  if(l == mid + 1 || mid == r)
    return sum[l][r];
  if(l <= mid && mid <= r) {
    return Secret(sum[l][mid], sum[mid + 1][r]);
  }
  if(r < mid)
    return solve(st, mid, l, r);
  return solve(mid + 1, dr, l, r);
}

int Query(int l, int r) {
  if(l == r)
    return v[l];
  if(l + 1 == r)
    return Secret(v[l], v[l + 1]);
  return solve(0, n - 1, l, r);
}

/*int main() {
  //ios_base :: sync_with_stdio(false);
  //cin.tie(0);
  //cout.tie(0);
  int n, Q, l, r, a[10005];
  cin >> n;
  cout << solve(0, 258, 250, 258) << "\n";
  for(int i = 0; i < n; i++)
    cin >> a[i];
  Init(n, a);
  cin >> Q;
  for(; Q; Q--) {
    cin >> l >> r;
    cout << Query(l, r) << "\n";
    int s = v[l];
    for(int i = l + 1; i <= r; i++)
      s = Secret(s, v[i]);
    cout << s << " right answer\n";
  }
  return 0;
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 140 ms 4372 KB Wrong Answer: Query(113, 206) - expected : 536899947, actual : 538256673.
2 Incorrect 132 ms 4460 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 134 ms 4460 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 492 ms 8428 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 510 ms 8428 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 495 ms 8288 KB Wrong Answer: Query(811, 813) - expected : 25091616, actual : 678362320.
7 Incorrect 505 ms 8216 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 494 ms 8300 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 492 ms 8428 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 529 ms 8448 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.