답안 #890834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890834 2023-12-22T04:01:22 Z NeroZein 말 (IOI15_horses) C++17
17 / 100
1500 ms 39548 KB
#include "horses.h"
#include "bits/stdc++.h"

using namespace std; 

const int N = 5e5 + 5; 
const int md = (int) 1e9 + 7;  

struct node {
  long double mx = 0, lazy = 0; 
};

int n;
int x[N], y[N];
node seg[N * 2]; 

int mul(int a, int b) {
  return (int) ((long long) a * b % md); 
}

void push(int nd, int l, int r) {
  if (!seg[nd].lazy) return;
  seg[nd].mx += seg[nd].lazy;
  if (l != r) {
    int mid = (l + r) >> 1;
    int rs = nd + ((mid - l + 1) << 1);
    seg[nd + 1].lazy += seg[nd].lazy;
    seg[rs].lazy += seg[nd].lazy; 
  }
  seg[nd].lazy = 0;
}

void upd(int nd, int l, int r, int s, int e, long double v) {
  push(nd, l, r);
  if (l >= s && r <= e) {
    seg[nd].lazy = v;
    push(nd, l, r);
    return; 
  }
  int mid = (l + r) >> 1;
  int rs = nd + ((mid - l + 1) << 1);
  if (mid >= e) {
    upd(nd + 1, l, mid, s, e, v);
    push(rs, mid + 1, r); 
  } else {
    if (mid < s) {
      upd(rs, mid + 1, r, s, e, v);
      push(nd + 1, l, mid);
    } else {
      upd(nd + 1, l, mid, s, e, v);
      upd(rs, mid + 1, r, s, e, v);
    }
  }
  seg[nd].mx = max(seg[nd + 1].mx, seg[rs].mx); 
}

int get(int nd, int l, int r) {
  if (l == r) {
    return l;
  }
  int mid = (l + r) >> 1;
  int rs = nd + ((mid - l + 1) << 1);
  push(nd + 1, l, mid);
  push(rs, mid + 1, r);
  if (seg[nd + 1].mx < seg[rs].mx) {
    return get(rs, mid + 1, r); 
  } else {
    return get(nd + 1, l, mid);
  }
}

int calc(int index) {
  int ret = 1;
  for (int i = 0; i <= index; ++i) {
    ret = mul(ret, x[i]);
  }
  return mul(ret, y[index]); 
}

int init(int N_, int X[], int Y[]) {
  n = N_;
  for (int i = 0; i < n; ++i) {
    x[i] = X[i]; y[i] = Y[i];
    upd(0, 0, n - 1, i, i, log2(y[i]));
    upd(0, 0, n - 1, i, n - 1, log2(x[i])); 
  }
  return calc(get(0, 0, n - 1));
}

int updateX(int pos, int val) { 
  upd(0, 0, n - 1, pos, n - 1, -log2(x[pos]));
  x[pos] = val;
  upd(0, 0, n - 1, pos, n - 1, +log2(x[pos]));
  return calc(get(0, 0, n - 1));
}

int updateY(int pos, int val) {
  upd(0, 0, n - 1, pos, pos, -y[pos]);
  y[pos] = val; 
  upd(0, 0, n - 1, pos, pos, +y[pos]);
  return calc(get(0, 0, n - 1));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 1 ms 4492 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4544 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4544 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4440 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 1 ms 4540 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4696 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Incorrect 1 ms 4440 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1529 ms 39548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4544 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4544 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4544 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4548 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4544 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Incorrect 1 ms 4444 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4552 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4440 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Incorrect 1 ms 4440 KB Output isn't correct
22 Halted 0 ms 0 KB -