Submission #729693

# Submission time Handle Problem Language Result Execution time Memory
729693 2023-04-24T11:17:09 Z NeroZein Game (IOI13_game) C++17
27 / 100
634 ms 27148 KB
#include "game.h"
#include <bits/stdc++.h> 

using namespace std; 

long long gcd2(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}

const int N = 1000005;

vector<vector<long long>> a;
int id; 
int rt[11];
long long seg[N << 2];

void build (int nd, int l, int r) {
  if (l == r) {
    id = max(id, nd); 
    return;
  }
  int mid = (l + r) >> 1;
  int rs = nd + ((mid - l + 1) << 1); 
  build(nd + 1, l, mid);
  build(rs, mid + 1, r); 
}

void upd (int nd, int l, int r, int p, long long v) {
  if (l == r) {
    seg[nd] = v; 
    return; 
  }
  int mid = (l + r) >> 1; 
  int rs = nd + ((mid - l + 1) << 1);
  if (p <= mid) {
    upd(nd + 1, l, mid, p, v); 
  } else {
    upd(rs, mid + 1, r, p, v); 
  }
  seg[nd] = __gcd(seg[nd + 1], seg[rs]); 
}

long long qry (int nd, int l, int r, int s, int e) {
  if (l >= s && r <= e) {
    return seg[nd] ;
  }
  int mid = (l + r) >> 1;
  int rs = nd + ((mid - l + 1) << 1);
  if (mid >= e) {
    return qry(nd + 1, l, mid, s, e); 
  } else {
    if (mid < s) {
      return qry(rs, mid + 1, r, s, e);
    } else {
      return gcd2(qry(nd + 1, l, mid, s, e), qry(rs, mid + 1, r, s, e)); 
    }
  }
}

int c, r;

void init(int R, int C) {
  a.resize(R); 
  r = R; c = C;
  for (int i = 0; i < R; ++i) {
    a[i].assign(C, 0);
  }
  for (int i = 0; i < R; ++i) {
    rt[i] = id + 1; 
    build(id + 1, 0, C - 1);
  }
}

void update(int P, int Q, long long K) {
  upd(rt[P], 0, c - 1, Q, K);
}

long long calculate(int P, int Q, int U, int V) {
  long long g = 0; 
  for (int i = P; i <= U; ++i) {
    g = gcd2(g, qry(rt[i], 0, c - 1, Q, V));
  }
  return g; 
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2 ms 852 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 634 ms 26764 KB Output is correct
5 Correct 482 ms 27148 KB Output is correct
6 Correct 539 ms 26812 KB Output is correct
7 Correct 551 ms 26328 KB Output is correct
8 Correct 436 ms 25948 KB Output is correct
9 Correct 555 ms 26444 KB Output is correct
10 Correct 497 ms 25992 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2 ms 852 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2 ms 888 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 2 ms 824 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -