답안 #135132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
135132 2019-07-23T16:30:28 Z Nucleist 게임 (IOI13_game) C++14
0 / 100
241 ms 256004 KB
#include <bits/stdc++.h> 
#include "game.h"
using namespace std; 
long long mx,m;
long long x,y;
long long tlx,trx,tly,tryi;
long long a[101][101]={0};
long long t[101*4][101*4]={0};
void init(int R,int C)
{
   for (long long i = 0; i < R; ++i)
   {
   	for (long long j = 0; j < C; ++j)
   	{
   		a[i][j]=0;
   	}
   }
}
void build_y(long long vx, long long lx, long long rx, long long vy, long long ly, long long ry) {
    if (ly == ry) {
        if (lx == rx)
            t[vx][vy] = a[lx][ly];
        else
            t[vx][vy] = __gcd(t[vx*2][vy],t[vx*2+1][vy]);
    } else {
        long long 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] = __gcd(t[vx][vy*2],t[vx][vy*2+1]);
    }
}

void build_x(long long vx, long long lx, long long rx) {
    if (lx != rx) {
        long long 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);
}
long long sum_y(long long vx, long long vy, long long tly, long long try_, long long ly, long long ry) {
    if (ly > ry) 
        return 0;
    if (ly == tly && try_ == ry)
        return t[vx][vy];
    long long tmy = (tly + try_) / 2;
    return __gcd(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));
}

long long sum_x(long long vx, long long tlx, long long trx, long long lx, long long rx, long long ly, long long ry) {
    if (lx > rx)
        return 0;
    if (lx == tlx && trx == rx)
        return sum_y(vx, 1, 0, m-1, ly, ry);
    long long tmx = (tlx + trx) / 2;
    return __gcd(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(long long vx, long long lx, long long rx, long long vy, long long ly, long long ry, long long x, long long y, long long new_val) {
    if (ly == ry) {
        if (lx == rx)
            t[vx][vy] = new_val;
        else
            t[vx][vy] = __gcd(t[vx*2][vy] , t[vx*2+1][vy]);
    } else {
        long long 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] = __gcd(t[vx][vy*2] , t[vx][vy*2+1]);
    }
}

void update_x(long long vx, long long lx, long long rx, long long x, long long y, long long new_val) {
    if (lx != rx) {
        long long 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);
}
void update(int P,int Q,long long value)
{
	update_x(1,0,x-1,P,Q,value);
}
long long calculate(int P,int Q,int U,int V)
{
	return sum_x(1,0,x-1,P,U,Q,V);
}


//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;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 222 ms 256004 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Runtime error 225 ms 256004 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 241 ms 256000 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Runtime error 218 ms 256000 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Runtime error 219 ms 256004 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -