# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
135108 |
2019-07-23T16:13:53 Z |
Nucleist |
Game (IOI13_game) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "game.h"
using namespace std;
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
template<class T>
bool operator()(T const &a, T const &b) const { return a > b; }
};
ll mx,m;
ll x,y;
ll tlx,trx,tly,tryi;
ll a[2001][2001]={0};
ll t[2001*4][2001*4]={0};
void init(ll R,ll C)
{
for (ll i = 0; i < R; ++i)
{
for (ll j = 0; j < C; ++j)
{
a[i][j]=0;
}
}
}
void build_y(ll vx, ll lx, ll rx, ll vy, ll ly, ll ry) {
if (ly == ry) {
if (lx == rx)
t[vx][vy] = a[lx][ly];
else
t[vx][vy] = gcd2(t[vx*2][vy],t[vx*2+1][vy]);
} else {
ll my = (ly + ry) / 2;
build_y(vx, lx, rx, vy*2, ly, my);
build_y(vx, lx, rx, vy*2+1, my+1, ry);
t[vx][vy] = gcd2(t[vx][vy*2],t[vx][vy*2+1]);
}
}
void build_x(ll vx, ll lx, ll rx) {
if (lx != rx) {
ll mx = (lx + rx) / 2;
build_x(vx*2, lx, mx);
build_x(vx*2+1, mx+1, rx);
}
build_y(vx, lx, rx, 1, 0, m-1);
}
ll sum_y(ll vx, ll vy, ll tly, ll try_, ll ly, ll ry) {
if (ly > ry)
return 0;
if (ly == tly && try_ == ry)
return t[vx][vy];
ll tmy = (tly + try_) / 2;
return gcd2(sum_y(vx, vy*2, tly, tmy, ly, min(ry, tmy))
,sum_y(vx, vy*2+1, tmy+1, try_, max(ly, tmy+1), ry));
}
ll sum_x(ll vx, ll tlx, ll trx, ll lx, ll rx, ll ly, ll ry) {
if (lx > rx)
return 0;
if (lx == tlx && trx == rx)
return sum_y(vx, 1, 0, m-1, ly, ry);
ll tmx = (tlx + trx) / 2;
return gcd2(sum_x(vx*2, tlx, tmx, lx, min(rx, tmx), ly, ry)
, sum_x(vx*2+1, tmx+1, trx, max(lx, tmx+1), rx, ly, ry));
}
void update_y(ll vx, ll lx, ll rx, ll vy, ll ly, ll ry, ll x, ll y, ll new_val) {
if (ly == ry) {
if (lx == rx)
t[vx][vy] = new_val;
else
t[vx][vy] = gcd2(t[vx*2][vy] , t[vx*2+1][vy]);
} else {
ll my = (ly + ry) / 2;
if (y <= my)
update_y(vx, lx, rx, vy*2, ly, my, x, y, new_val);
else
update_y(vx, lx, rx, vy*2+1, my+1, ry, x, y, new_val);
t[vx][vy] = gcd2(t[vx][vy*2] , t[vx][vy*2+1]);
}
}
void update_x(ll vx, ll lx, ll rx, ll x, ll y, ll new_val) {
if (lx != rx) {
ll mx = (lx + rx) / 2;
if (x <= mx)
update_x(vx*2, lx, mx, x, y, new_val);
else
update_x(vx*2+1, mx+1, rx, x, y, new_val);
}
update_y(vx, lx, rx, 1, 0, m-1, x, y, new_val);
}
ll calculate(ll P,ll Q,ll U,ll V)
{
return sum_x(1,0,x-1,P,U,Q,V);
}
void update(ll P,ll Q,ll value)
{
update_x(1,0,x-1,P,Q,value);
}
//code the AC sol !
// BS/queue/map
Compilation message
grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
int res;
^~~
game.cpp: In function 'void build_y(long long int, long long int, long long int, long long int, long long int, long long int)':
game.cpp:37:25: error: 'gcd2' was not declared in this scope
t[vx][vy] = gcd2(t[vx*2][vy],t[vx*2+1][vy]);
^~~~
game.cpp:37:25: note: suggested alternative: 'gcvt'
t[vx][vy] = gcd2(t[vx*2][vy],t[vx*2+1][vy]);
^~~~
gcvt
game.cpp:42:21: error: 'gcd2' was not declared in this scope
t[vx][vy] = gcd2(t[vx][vy*2],t[vx][vy*2+1]);
^~~~
game.cpp:42:21: note: suggested alternative: 'gcvt'
t[vx][vy] = gcd2(t[vx][vy*2],t[vx][vy*2+1]);
^~~~
gcvt
game.cpp: In function 'long long int sum_y(long long int, long long int, long long int, long long int, long long int, long long int)':
game.cpp:60:12: error: 'gcd2' was not declared in this scope
return gcd2(sum_y(vx, vy*2, tly, tmy, ly, min(ry, tmy))
^~~~
game.cpp:60:12: note: suggested alternative: 'gcvt'
return gcd2(sum_y(vx, vy*2, tly, tmy, ly, min(ry, tmy))
^~~~
gcvt
game.cpp: In function 'long long int sum_x(long long int, long long int, long long int, long long int, long long int, long long int, long long int)':
game.cpp:70:12: error: 'gcd2' was not declared in this scope
return gcd2(sum_x(vx*2, tlx, tmx, lx, min(rx, tmx), ly, ry)
^~~~
game.cpp:70:12: note: suggested alternative: 'gcvt'
return gcd2(sum_x(vx*2, tlx, tmx, lx, min(rx, tmx), ly, ry)
^~~~
gcvt
game.cpp: In function 'void update_y(long long int, long long int, long long int, long long int, long long int, long long int, long long int, long long int, long long int)':
game.cpp:78:25: error: 'gcd2' was not declared in this scope
t[vx][vy] = gcd2(t[vx*2][vy] , t[vx*2+1][vy]);
^~~~
game.cpp:78:25: note: suggested alternative: 'gcvt'
t[vx][vy] = gcd2(t[vx*2][vy] , t[vx*2+1][vy]);
^~~~
gcvt
game.cpp:85:21: error: 'gcd2' was not declared in this scope
t[vx][vy] = gcd2(t[vx][vy*2] , t[vx][vy*2+1]);
^~~~
game.cpp:85:21: note: suggested alternative: 'gcvt'
t[vx][vy] = gcd2(t[vx][vy*2] , t[vx][vy*2+1]);
^~~~
gcvt