이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// In the name of Allah
#include <bits/stdc++.h>
#include "game.h"
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> cld;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0)
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m;
const int maxn = 100 + 3;
vector<ll> t[maxn];
void set_val(int ind, int v, int tl, int tr, int i, ll x) {
if (i >= tr || i < tl) return ;
if (tr - tl == 1) {
t[ind][v] = x;
return ;
}
int mid = (tl + tr) / 2;
set_val(ind, 2 * v + 1, tl, mid, i, x);
set_val(ind, 2 * v + 2, mid, tr, i, x);
t[ind][v] = __gcd(t[ind][2 * v + 1], t[ind][2 * v + 2]);
}
ll get_gcd(int ind, int v, int tl, int tr, int l, int r) {
l = max(l, tl); r = min(r, tr);
if (l >= tr || r <= tl) return 0;
if (l == tl && r == tr) return t[ind][v];
int mid = (tl + tr) / 2;
return __gcd(get_gcd(ind, 2 * v + 1, tl, mid, l, r), get_gcd(ind, 2 * v + 2, mid, tr, l, r));
}
void init(int R, int C) {
n = R; m = C;
for (int i = 0; i < n; i++) t[i].resize(4 * m);
return ;
}
void update(int i, int j, ll R) {
if (n >= maxn) return ;
set_val(i, 0, 0, m, j, R);
}
ll calculate(int l1, int l2, int r1, int r2) {
if (n >= maxn) return 0;
r1++; r2++; ll res = 0;
for (int i = l1; i < r1; i++) {
res = __gcd(res, get_gcd(i, 0, 0, m, l2, r2));
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |