Submission #340096

# Submission time Handle Problem Language Result Execution time Memory
340096 2020-12-26T21:56:20 Z MilosMilutinovic Secret (JOI14_secret) C++14
0 / 100
503 ms 4716 KB
/**
 *  author: milos
 *  created: 26.12.2020 00:20:30
**/
#include "secret.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> a;

/*int Secret(int l, int r) {
  return l + r;  
}*/

vector<pair<int, pair<vector<long long>, vector<long long>>>> ans;

int Query(int l, int r) {
  for (auto c : ans) {
    if (c.first >= l && c.first <= r) {
      if (r == c.first) {
        int j = c.first - l;
        return c.second.first[j];
      }
      int j = c.first - l, z = r - c.first - 1;
      return Secret(c.second.first[j], c.second.second[z]);
    }
  }
  return 0;  
}

void Solve(int l, int r) {
  if (l > r) {
    return;
  }
  int mid = (l + r) / 2; 
  vector<long long> pref, suf;
  long long x = a[mid];
  pref.push_back(x);
  for (int i = mid - 1; i >= l; i--) {
    x = Secret(x, a[i]);
    pref.push_back(x);  
  }
  if (mid + 1 < (int) a.size()) {
    x = a[mid + 1];
    suf.push_back(x);
    for (int i = mid + 2; i <= r; i++) {
      x = Secret(x, a[i]);
      suf.push_back(x);
    }
  }
  ans.push_back({mid, {pref, suf}});
  Solve(l, mid - 1);
  Solve(mid + 1, r);    
}

void Init(int N, int* A) {
  for (int i = 0; i < N; i++) {
    a.push_back(A[i]);
  }
  Solve(0, N - 1);    
}
# Verdict Execution time Memory Grader output
1 Incorrect 130 ms 2540 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 132 ms 2456 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 131 ms 2540 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 503 ms 4716 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 489 ms 4460 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 493 ms 4588 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 850129153.
7 Incorrect 497 ms 4588 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 496 ms 4460 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 494 ms 4644 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 492 ms 4588 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.