Submission #751988

#TimeUsernameProblemLanguageResultExecution timeMemory
751988boyliguanhanGame (IOI13_game)C++17
80 / 100
3873 ms256000 KiB
#include "game.h" #include<bits/stdc++.h> #define N 660100 using namespace std; #define mid (l+r>>1) #define ll long long #define M 25000000 int rt[N], ch1[N][2], ch2[M][2], cnt1, cnt2, root, MX, MY; ll val[M]; ll query2(int i, int x, int y, int l, int r) { if(!i||y<l||r<x) return 0; if(x<=l&&r<=y) return val[i]; return gcd(query2(ch2[i][0],x,y,l,mid), query2(ch2[i][1], x, y, mid+1, r)); } void upd2(int &i, ll x, int p, int l, int r) { if(!i)i=++cnt2;if(l==r)return(void)(val[i]=x); if(p<=mid) upd2(ch2[i][0], x, p, l, mid); else upd2(ch2[i][1], x, p, mid + 1, r); val[i] = gcd(val[ch2[i][0]], val[ch2[i][1]]); } void maint(int &i, int p, int i2, int i3, int l, int r) { if(!i)i=++cnt2;val[i]=gcd(val[i2], val[i3]);if(l-r) if(p<=mid) maint(ch2[i][0], p, ch2[i2][0], ch2[i3][0], l, mid); else maint(ch2[i][1], p, ch2[i2][1], ch2[i3][1], mid + 1, r); } ll query1(int i, int x, int y, int u, int v, int l, int r) { if(!i||y<l||r<x)return 0;if(x <= l && r <= y)return query2(rt[i], u, v, 0, MY); return gcd(query1(ch1[i][0],x,y,u,v,l,mid),query1(ch1[i][1],x,y,u,v,mid + 1,r)); } void upd1(int &i, ll x, int p1, int p2, int l, int r) { if(!i) i = ++cnt1; if(l!=r){if(p1<=mid)upd1(ch1[i][0],x,p1,p2,l,mid); else upd1(ch1[i][1], x, p1, p2, mid+1,r); maint(rt[i], p2, rt[ch1[i][0]], rt[ch1[i][1]],0,MY);} else upd2(rt[i],x,p2,0,MY); } void init(int R, int C) {MX = R - 1, MY = C - 1;} void update(int P, int Q, ll K) {upd1(root, K, P, Q, 0, MX);} ll calculate(int P,int Q,int U,int V){return query1(root,P,U,Q,V,0,MX);}

Compilation message (stderr)

game.cpp: In function 'long long int query2(int, int, int, int, int)':
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:12:39: note: in expansion of macro 'mid'
   12 |     return gcd(query2(ch2[i][0],x,y,l,mid),
      |                                       ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:13:33: note: in expansion of macro 'mid'
   13 |         query2(ch2[i][1], x, y, mid+1, r));
      |                                 ^~~
game.cpp: In function 'void upd2(int&, long long int, int, int, int)':
game.cpp:16:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |     if(!i)i=++cnt2;if(l==r)return(void)(val[i]=x);
      |     ^~
game.cpp:16:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |     if(!i)i=++cnt2;if(l==r)return(void)(val[i]=x);
      |                    ^~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:17:11: note: in expansion of macro 'mid'
   17 |     if(p<=mid) upd2(ch2[i][0], x, p, l, mid);
      |           ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:17:41: note: in expansion of macro 'mid'
   17 |     if(p<=mid) upd2(ch2[i][0], x, p, l, mid);
      |                                         ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:18:32: note: in expansion of macro 'mid'
   18 |     else upd2(ch2[i][1], x, p, mid + 1, r);
      |                                ^~~
game.cpp: In function 'void maint(int&, int, int, int, int, int)':
game.cpp:22:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   22 |     if(!i)i=++cnt2;val[i]=gcd(val[i2], val[i3]);if(l-r)
      |     ^~
game.cpp:22:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   22 |     if(!i)i=++cnt2;val[i]=gcd(val[i2], val[i3]);if(l-r)
      |                    ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:23:11: note: in expansion of macro 'mid'
   23 |     if(p<=mid) maint(ch2[i][0], p, ch2[i2][0], ch2[i3][0], l, mid);
      |           ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:23:63: note: in expansion of macro 'mid'
   23 |     if(p<=mid) maint(ch2[i][0], p, ch2[i2][0], ch2[i3][0], l, mid);
      |                                                               ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:24:54: note: in expansion of macro 'mid'
   24 |     else maint(ch2[i][1], p, ch2[i2][1], ch2[i3][1], mid + 1, r);
      |                                                      ^~~
game.cpp:22:51: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   22 |     if(!i)i=++cnt2;val[i]=gcd(val[i2], val[i3]);if(l-r)
      |                                                   ^
game.cpp: In function 'long long int query1(int, int, int, int, int, int, int)':
game.cpp:27:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   27 |     if(!i||y<l||r<x)return 0;if(x <= l && r <= y)return query2(rt[i], u, v, 0, MY);
      |     ^~
game.cpp:27:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   27 |     if(!i||y<l||r<x)return 0;if(x <= l && r <= y)return query2(rt[i], u, v, 0, MY);
      |                              ^~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:28:43: note: in expansion of macro 'mid'
   28 |     return gcd(query1(ch1[i][0],x,y,u,v,l,mid),query1(ch1[i][1],x,y,u,v,mid + 1,r));
      |                                           ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:28:73: note: in expansion of macro 'mid'
   28 |     return gcd(query1(ch1[i][0],x,y,u,v,l,mid),query1(ch1[i][1],x,y,u,v,mid + 1,r));
      |                                                                         ^~~
game.cpp: In function 'void upd1(int&, long long int, int, int, int, int)':
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:32:21: note: in expansion of macro 'mid'
   32 |     if(l!=r){if(p1<=mid)upd1(ch1[i][0],x,p1,p2,l,mid);
      |                     ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:32:50: note: in expansion of macro 'mid'
   32 |     if(l!=r){if(p1<=mid)upd1(ch1[i][0],x,p1,p2,l,mid);
      |                                                  ^~~
game.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    5 | #define mid (l+r>>1)
      |              ~^~
game.cpp:33:37: note: in expansion of macro 'mid'
   33 |     else upd1(ch1[i][1], x, p1, p2, mid+1,r);
      |                                     ^~~
#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...