# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
224667 |
2020-04-18T14:39:58 Z |
T0p_ |
게임 (IOI13_game) |
C++14 |
|
1999 ms |
256004 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int _R, _C;
struct node2
{
int l, r;
long long v;
node2 *L, *R;
node2(int a, int b)
{
l = a;
r = b;
v = 0;
L = R = NULL;
}
void extend()
{
if(!L && l != r)
{
int mid = (l+r)>>1;
L = new node2(l, mid);
R = new node2(mid+1, r);
}
}
};
struct node1
{
int l, r;
long long v;
node2 *now;
node1 *L, *R;
node1(int a, int b, int c, int d)
{
l = a;
r = b;
v = 0;
now = new node2(c, d);
L = R = NULL;
}
void extend()
{
if(!L && l != r)
{
int mid = (l+r)>>1;
L = new node1(1, mid, 1, _C);
R = new node1(mid+1, r, 1, _C);
}
}
};
node1 *root;
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)
{
_R = R, _C = C;
root = new node1(1, R, 1, C);
}
void update2(node2 *seg, int p, long long k)
{
seg->extend();
if(!(seg->l <= p && p <= seg->r)) return ;
if(seg->l == seg->r) return void(seg->v = k);
update2(seg->L, p, k);
update2(seg->R, p, k);
seg->v = gcd2(seg->L->v, seg->R->v);
}
void push(node2 *seg, node2 *L, node2 *R, int p)
{
seg->extend();
L->extend();
R->extend();
if(!(seg->l <= p && p <= seg->r)) return ;
if(seg->l == seg->r) return ;
push(seg->L, L->L, R->L, p);
push(seg->R, L->R, R->R, p);
seg->v = gcd2(L->v, R->v);
}
void update1(node1 *seg, int p, int q, long long k)
{
seg->extend();
if(!(seg->l <= p && p <= seg->r)) return;
if(seg->l == seg->r)return void(update2(seg->now, q, k));
update1(seg->L, p, q, k);
update1(seg->R, p, q, k);
push(seg->now, seg->L->now, seg->R->now, q);
}
void update(int P, int Q, long long K) {
P++, Q++;
update1(root, P, Q, K);
}
long long query2(node2 *seg, int a, int b)
{
seg->extend();
if(seg->r < a || b < seg->l) return 0;
if(a <= seg->l && seg->r <= b) return seg->v;
return gcd2(query2(seg->L, a, b), query2(seg->R, a, b));
}
long long query1(node1 *seg, int a, int b, int c, int d)
{
seg->extend();
if(seg->r < a || b < seg->l) return 0;
if(a <= seg->l && seg->r <= b) return query2(seg->now, c, d);
return gcd2(query1(seg->L, a, b, c, d), query1(seg->R, a, b, c, d));
}
long long calculate(int P, int Q, int U, int V) {
P++, Q++, U++, V++;
return query1(root, P, U, Q, V);
}
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 |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
10 ms |
4224 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
1999 ms |
106564 KB |
Output is correct |
5 |
Correct |
916 ms |
87672 KB |
Output is correct |
6 |
Runtime error |
1531 ms |
256004 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Incorrect |
9 ms |
4224 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
10 ms |
4224 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
9 ms |
4224 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |