# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
133334 |
2019-07-20T12:15:47 Z |
amiratou |
Game (IOI13_game) |
C++14 |
|
858 ms |
44612 KB |
#pragma GCC optimize("O3")
#include "game.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
ll st[45][400002];
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) {
n=R,m=C;
}
void update_y(int node,int l,int r,int node_x,int lx,int rx,int y,ll val){
if(l>y||r<y)
return ;
if(l==r){
if(lx==rx)st[node_x][node]=val;
else st[node_x][node]=gcd2(st[node_x<<1][node],st[(node_x<<1)+1][node]);
return ;
}
int med=((l+r)>>1);
update_y((node<<1),l,med,node_x,lx,rx,y,val);
update_y((node<<1)+1,med+1,r,node_x,lx,rx,y,val);
st[node_x][node]=gcd2(st[node_x][(node<<1)],st[node_x][(node<<1)+1]);
}
void update_x(int node,int l,int r,int x,int y,ll val){
if(l>x||r<x)
return ;
if(l!=r){
int med=((l+r)>>1);
update_x((node<<1),l,med,x,y,val);
update_x((node<<1)+1,med+1,r,x,y,val);
}
update_y(1,0,m-1,node,l,r,y,val);
}
ll query_y(int node,int l,int r,int node_x,int y1,int y2){
if(l>y2||r<y1)
return 0LL;
if(l>=y1&&r<=y2)
return st[node_x][node];
int med=((l+r)>>1);
return gcd2(query_y((node<<1),l,med,node_x,y1,y2),query_y((node<<1)+1,med+1,r,node_x,y1,y2));
}
ll query_x(int node,int l,int r,int x1,int y1,int x2,int y2){
if(l>x2||r<x1)
return 0LL;
if(l>=x1&&r<=x2)
return query_y(1,0,m-1,node,y1,y2);
int med=((l+r)>>1);
return gcd2(query_x((node<<1),l,med,x1,y1,x2,y2),query_x((node<<1)+1,med+1,r,x1,y1,x2,y2));
}
void update(int P, int Q, ll K) {
update_x(1,0,n-1,P,Q,K);
}
long long calculate(int P, int Q, int U, int V) {
return query_x(1,0,n-1,P,Q,U,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;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Runtime error |
10 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
858 ms |
39652 KB |
Output is correct |
5 |
Correct |
597 ms |
43520 KB |
Output is correct |
6 |
Correct |
838 ms |
44612 KB |
Output is correct |
7 |
Correct |
853 ms |
44260 KB |
Output is correct |
8 |
Correct |
676 ms |
42180 KB |
Output is correct |
9 |
Correct |
844 ms |
44208 KB |
Output is correct |
10 |
Correct |
717 ms |
43856 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
10 ms |
496 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
10 ms |
476 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
10 ms |
412 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |