This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define ryan bear
#define all(V) ((V).begin()), ((V).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<int> vim;
typedef vector<ll> vlm;
int R, C;
struct dt1 {
dt1 *l, *r;
ll dt;
dt1() {l=r=NULL; dt=0;}
ll upd(int y, ll val, int fr, int re) {
if (!(fr<=y&&y<=re)) return dt;
if (fr==re) {dt=val; return dt;}
int md=(fr+re)/2;
if (l==NULL) l=new dt1();
if (r==NULL) r=new dt1();
return dt=__gcd(l->upd(y, val, fr, md), r->upd(y, val, md+1, re));
}
ll get(int y1, int y2, int fr, int re) {
if (fr>re||y2<fr||re<y1) return 0;
if (y1<=fr&&re<=y2) return dt;
int md=(fr+re)/2;
return __gcd((l?l->get(y1, y2, fr, md):0), (r?r->get(y1, y2, md+1, re):0));
}
};
struct dt2 {
dt2 *l, *r;
dt1 *seg;
dt2() {l=r=NULL; seg=new dt1();}
void upd(int x, int y, ll val, int fr, int re) {
if (!(fr<=x&&x<=re)) return ;
seg->upd(y, val, 0, C-1);
if (fr==re) return ;
if (l==NULL) l=new dt2();
if (r==NULL) r=new dt2();
int md=(fr+re)/2;
l->upd(x, y, val, fr, md);
r->upd(x, y, val, md+1, re);
}
ll get(int x1, int x2, int y1, int y2, int fr, int re) {
if (fr>re||x2<fr||re<x1) return 0;
if (x1<=fr&&re<=x2) return seg->get(y1, y2, 0, C-1);
int md=(fr+re)/2;
return __gcd((l?(l->get(x1, x2, y1, y2, fr, md)):0), (r?(r->get(x1, x2, y1, y2, md+1, re)):0));
}
};
dt2 *root=new dt2();
void init(int r_, int c_) {
R=r_, C=c_;
}
void update(int P, int Q, ll K) {
root->upd(P, Q, K, 0, R-1);
}
ll calculate(int P, int Q, int U, int V) {
return root->get(P, U, Q, V, 0, R-1);
}
Compilation message (stderr)
grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
int 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... |