Submission #171172

#TimeUsernameProblemLanguageResultExecution timeMemory
171172dennisstarGame (IOI13_game)C++11
37 / 100
13097 ms8440 KiB
#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 *l1, *l2, *r1, *r2; ll dt; dt1() {l1=l2=r1=r2=NULL; dt=0;} inline void upd(int x, int y, ll val, int xs, int xe, int ys, int ye) { if (xs==xe&&ys==ye) {dt=val; return ;} int xm=(xs+xe)/2, ym=(ys+ye)/2; if (x<=xm) { if (y<=ym) { if (!l1) l1=new dt1(); l1->upd(x, y, val, xs, xm, ys, ym); } else { if (!r1) r1=new dt1(); r1->upd(x, y, val, xs, xm, ym+1, ye); } } else { if (y<=ym) { if (!l2) l2=new dt1(); l2->upd(x, y, val, xm+1, xe, ys, ym); } else { if (!r2) r2=new dt1(); r2->upd(x, y, val, xm+1, xe, ym+1, ye); } } ll L1, L2, R1, R2; L1=(l1?l1->dt:0); L2=(l2?l2->dt:0); R1=(r1?r1->dt:0); R2=(r2?r2->dt:0); dt=__gcd(__gcd(L1, L2), __gcd(R1, R2)); } inline ll get(int x1, int x2, int y1, int y2, int xs, int xe, int ys, int ye) { if (xs>xe||ys>ye) return 0; if (x1<=xs&&xe<=x2&&y1<=ys&&ye<=y2) return dt; int xm=(xs+xe)/2, ym=(ys+ye)/2; ll L1, L2, R1, R2; L1=L2=R1=R2=0; if (!(xm<x1)) { if (!(ym<y1)) L1=(l1?l1->get(x1, x2, y1, y2, xs, xm, ys, ym):0); if (!(y2<ym+1)) R1=(r1?r1->get(x1, x2, y1, y2, xs, xm, ym+1, ye):0); } if (!(x2<xm+1)) { if (!(ym<y1)) L2=(l2?l2->get(x1, x2, y1, y2, xm+1, xe, ys, ym):0); if (!(y2<ym+1)) R2=(r2?r2->get(x1, x2, y1, y2, xm+1, xe, ym+1, ye):0); } return __gcd(__gcd(L1, L2), __gcd(R1, R2)); } }; dt1 *root=new dt1(); 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, 0, C-1); } ll calculate(int P, int Q, int U, int V) { return root->get(P, U, Q, V, 0, R-1, 0, C-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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...