Submission #41566

# Submission time Handle Problem Language Result Execution time Memory
41566 2018-02-19T07:38:54 Z funcsr Secret (JOI14_secret) C++14
6 / 100
1231 ms 13480 KB
#include "secret.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define index(x, y) (int)(lower_bound(all(x), y) - x.begin())
#define pb push_back
#define MAX_N (1<<10)
typedef pair<int, int> P;
int seg[MAX_N*2-1];
map<P, int> mp;
int ask(int x, int y) {
  if (mp.find(P(x, y)) != mp.end()) return mp[P(x, y)];
  return mp[P(x, y)] = Secret(x, y);
}
int N;
int A[1000];
int Tleft[1000][1000], Tright[1000][1000];
void precalc(int l, int r) {
  if (l == r) return;
  int mid = (l+r)/2;
  Tleft[mid][mid] = A[mid];
  for (int x=mid-1; x>=0; x--) Tleft[mid][x] = Secret(A[x], Tleft[mid][x+1]);
  Tright[mid][mid+1] = A[mid+1];
  for (int x=mid+2; x<=r; x++) Tright[mid][x] = Secret(Tright[mid][x-1], A[x]);

  precalc(l, mid);
  precalc(mid+1, r);
}
int f(int l, int r, int a, int b) {
  if (l == r) return A[l];
  int mid = (l+r)/2;
  if (a <= mid && mid <= b) {
    int x = Tleft[mid][a];
    if (mid < b) x = Secret(x, Tright[mid][b]);
    return x;
  }
  if (b < mid) return f(l, mid, a, b);
  else return f(mid+1, r, a, b);
}

void Init(int NN, int AA[]) {
  N = NN;
  rep(i, N) A[i] = AA[i];
  precalc(0, N-1);
}

int Query(int L, int R) {
  return f(0, N-1, L, R);
}
# Verdict Execution time Memory Grader output
1 Incorrect 316 ms 6672 KB Output isn't correct - number of calls to Secret by Init = 131580, maximum number of calls to Secret by Query = 1
2 Incorrect 325 ms 6832 KB Output isn't correct - number of calls to Secret by Init = 132098, maximum number of calls to Secret by Query = 1
3 Incorrect 323 ms 6908 KB Output isn't correct - number of calls to Secret by Init = 132609, maximum number of calls to Secret by Query = 1
4 Incorrect 1195 ms 12892 KB Output isn't correct - number of calls to Secret by Init = 501429, maximum number of calls to Secret by Query = 1
5 Incorrect 1219 ms 13028 KB Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1
6 Incorrect 1202 ms 13148 KB Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1
7 Incorrect 1188 ms 13204 KB Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1
8 Incorrect 1168 ms 13204 KB Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1
9 Incorrect 1195 ms 13480 KB Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1
10 Incorrect 1231 ms 13480 KB Output isn't correct - number of calls to Secret by Init = 502434, maximum number of calls to Secret by Query = 1