Submission #574166

#TimeUsernameProblemLanguageResultExecution timeMemory
574166Theo830Game (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define ull unsigned ll #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "game.h" struct sp{ ll l = -1,r = -1; }; vector<sp>py,px; ll seg[30000][30000]; ll cx = 1,cy = 1; ll N,M; ll em = 1000000; void init(int R, int C){ sp A; py.assign(em,A); px.assign(em,A); N = R; M = C; } void upd_y(ll lx,ll rx,ll curx,ll ly,ll ry,ll cury,ll X,ll Y,ll val){ if(ly == ry){ if(lx == rx){ seg[curx][cury] = val; } else{ seg[curx][cury] = 0; if(px[curx].l != -1){ ll pos = seg[px[curx].l][cury]; seg[curx][cury] = __gcd(seg[curx][cury],pos); } if(px[curx].r != -1){ ll pos = seg[px[curx].r][cury]; seg[curx][cury] = __gcd(seg[curx][cury],pos); } } } else{ ll mid = (ly+ry)/2; if(Y <= mid){ if(py[cury].l == -1){ py[cury].l = cy; cy++; } upd_y(lx,rx,curx,ly,mid,py[cury].l,X,Y,val); } else{ if(py[cury].r == -1){ py[cury].r = cy; cy++; } upd_y(lx,rx,curx,mid+1,ry,py[cury].r,X,Y,val); } seg[curx][cury] = 0; if(py[cury].l != -1){ ll pos = py[cury].l; seg[curx][cury] = __gcd(seg[curx][cury],seg[curx][pos]); } if(py[cury].r != -1){ ll pos = py[cury].r; seg[curx][cury] = __gcd(seg[curx][cury],seg[curx][pos]); } } } void upd_x(ll lx,ll rx,ll curx,ll X,ll Y,ll val){ if(lx != rx){ ll mid = (lx + rx) / 2; if(X <= mid){ if(px[curx].l == -1){ px[curx].l = cx; cx++; } upd_x(lx,mid,px[curx].l,X,Y,val); } else{ if(px[curx].r == -1){ px[curx].r = cx; cx++; } upd_x(mid+1,rx,px[curx].r,X,Y,val); } } upd_y(lx,rx,curx,0,M-1,0,X,Y,val); } ll ask_y(ll lx,ll rx,ll curx,ll ly,ll ry,ll cury,ll X1,ll X2,ll Y1,ll Y2){ if(Y1 <= ly && ry <= Y2){ return seg[curx][cury]; } if(ly > Y2 || Y1 > ry){ return 0; } ll ans = 0; ll mid = (ly + ry) / 2; if(py[cury].l != -1){ ans = __gcd(ans,ask_y(lx,rx,curx,ly,mid,py[cury].l,X1,X2,Y1,Y2)); } if(py[cury].r != -1){ ans = __gcd(ans,ask_y(lx,rx,curx,mid+1,ry,py[cury].r,X1,X2,Y1,Y2)); } return ans; } ll ask_x(ll lx,ll rx,ll curx,ll X1,ll X2,ll Y1,ll Y2){ if(X1 <= lx && rx <= X2){ return ask_y(lx,rx,curx,0,M-1,0,X1,X2,Y1,Y2); } if(lx > X2 || X1 > rx){ return 0; } ll ans = 0; ll mid = (lx + rx) / 2; if(px[curx].l != -1){ ans = __gcd(ans,ask_x(lx,mid,px[curx].l,X1,X2,Y1,Y2)); } if(px[curx].r != -1){ ans = __gcd(ans,ask_x(mid+1,rx,px[curx].r,X1,X2,Y1,Y2)); } return ans; } void update(int P, int Q, long long K) { upd_x(0,N-1,0,P,Q,K); } long long calculate(int P, int Q, int U, int V) { return ask_x(0,N-1,0,P,U,Q,V); } /* #define MAX_SIZE 1000000000 #define MAX_N 272000 int main() { ios_base::sync_with_stdio(0); cin.tie(0); int R, C, N; int P, Q, U, V; long long K; int i, type; int res; res = scanf("%d", &R); res = scanf("%d", &C); res = scanf("%d", &N); init(R, C); for (i = 0; i < N; i++) { res = scanf("%d", &type); if (type == 1) { res = scanf("%d%d%lld", &P, &Q, &K); update(P, Q, K); } else if (type == 2) { res = scanf("%d%d%d%d", &P, &Q, &U, &V); cout<<calculate(P, Q, U, V)<<"\n"; } } return 0; } 2 3 9 1 0 0 20 1 0 2 15 1 1 1 12 2 0 0 0 2 2 0 0 1 1 1 0 1 6 1 1 1 14 2 0 0 0 2 2 0 0 1 1 */

Compilation message (stderr)

/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status