답안 #137284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137284 2019-07-27T12:00:57 Z TuGSGeReL 게임 (IOI13_game) C++17
0 / 100
3113 ms 32564 KB
#include "game.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;

int rr, cc;
ll k;
unordered_map <int, unordered_map<int, ll> > sgx;
unordered_map <int, int> which;

long long gcd2(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}

void init(int R, int C) {
	rr = R;
	cc = C;
	k = log2(R);
	
	if ( pow(2, k) != R )
		k++;
	
	k = pow(2, k) - 1;
}

void updy(int node, int l, int r, int idx, ll d, int whi)
{
	if ( l == r && r == idx )
	{
		sgx[whi][node] = d;
		
		do{
			whi >>= 1;
			sgx[whi][node] = gcd2(sgx[whi << 1][node], sgx[(whi << 1) + 1][node]);
		}while(whi > 1);
		
		return;
	}
	
	int mid = (l + r) >> 1;
	
	if ( idx <= mid )
		updy(node << 1, l, mid, idx, d, whi);
	
	else
		updy((node << 1) + 1, mid + 1, r, idx, d, whi);
	
	sgx[whi][node] = gcd2(sgx[whi][node << 1], sgx[whi][(node << 1) + 1]);
	
	do{
		whi >>= 1;
		sgx[whi][node] = gcd2(sgx[whi << 1][node], sgx[(whi << 1) + 1][node]);
	}while(whi > 1);
}


ll lqu(int node, int l, int r, int L, int R, int whi)
{
	if ( l > R || r < L )
		return 0;
		
	if ( l >= L && r <= R )
		return sgx[whi][node];
	
	int mid = (l + r) >> 1;
	
	return gcd2(lqu(node << 1, l, mid, L, R, whi), lqu((node << 1) + 1, mid + 1, r, L, R, whi));
}

ll query (int node, int l, int r, int lx, int ly, int rx, int ry)
{
	if ( l > rx || r < lx )
		return 0;
	
	if ( l >= lx && r <= rx )
		return lqu(1, 1, cc, ly, ry, node);
	
	int mid = (l + r) >> 1;
	
	return gcd2(query(node << 1, l, mid, lx, ly, rx, ry), query((node << 1) + 1, mid + 1, r, lx, ly, rx, ry));
}

void update(int P, int Q, ll K) {
	updy(1, 1, cc, Q + 1, K, k + P + 1);
}

ll calculate(int P, int Q, int U, int V) {
	return query(1, 1, rr, P + 1, Q + 1, U + 1, V + 1);
}

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 Incorrect 5 ms 632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 3113 ms 32564 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 5 ms 632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 5 ms 632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 5 ms 632 KB Output isn't correct
3 Halted 0 ms 0 KB -