#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<long long int>st[101];
void init(int R,int C)
{
n=R;
m=C;
for(int i=0;i<n;i++)
{
st[i].resize(4*m+1);
}
}
void updatest(int i,int l,int r,int a,int b,long long int k)
{
if(l==r)
{
st[a][i]=k;
return;
}
int m=(l+r)/2;
if(b<=m)updatest(i*2,l,m,a,b,k);
else
{
updatest(i*2+1,m+1,r,a,b,k);
}
st[a][i]=gcd(st[a][i*2],st[a][i*2+1]);
}
long long int gsum(int i,int l,int r,int tl,int tr,int a)
{
if(tl>r||tr<l||l>r)
{
return 0;
}
if(tl<=l&&r<=tr)
{
return st[a][i];
}
int m=(l+r)/2;
return gcd(gsum(i*2,l,m,tl,tr,a),gsum(i*2+1,m+1,r,tl,tr,a));
}
long long int calculate(int r1,int r2,int c1,int c2)
{
long long int sum=0;
for(int i=r1;i<=c1;i++)
{
sum=gcd(sum,gsum(1,0,m-1,r2,c2,i));
}
return sum;
}
void update(int R,int C,long long int k)
{
updatest(1,0,m-1,R,C,k);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
629 ms |
35668 KB |
Output is correct |
5 |
Correct |
454 ms |
36040 KB |
Output is correct |
6 |
Correct |
603 ms |
32848 KB |
Output is correct |
7 |
Correct |
551 ms |
32568 KB |
Output is correct |
8 |
Correct |
462 ms |
33296 KB |
Output is correct |
9 |
Correct |
560 ms |
32636 KB |
Output is correct |
10 |
Correct |
473 ms |
32040 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Runtime error |
4 ms |
7004 KB |
Execution killed with signal 11 |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
612 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
616 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
602 ms |
35672 KB |
Output is correct |
13 |
Correct |
402 ms |
35924 KB |
Output is correct |
14 |
Correct |
518 ms |
32852 KB |
Output is correct |
15 |
Correct |
541 ms |
32580 KB |
Output is correct |
16 |
Correct |
422 ms |
33392 KB |
Output is correct |
17 |
Correct |
555 ms |
32596 KB |
Output is correct |
18 |
Correct |
447 ms |
32052 KB |
Output is correct |
19 |
Runtime error |
4 ms |
7004 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
619 ms |
35660 KB |
Output is correct |
13 |
Correct |
428 ms |
35924 KB |
Output is correct |
14 |
Correct |
513 ms |
32816 KB |
Output is correct |
15 |
Correct |
516 ms |
32332 KB |
Output is correct |
16 |
Correct |
438 ms |
33284 KB |
Output is correct |
17 |
Correct |
513 ms |
32556 KB |
Output is correct |
18 |
Correct |
439 ms |
32084 KB |
Output is correct |
19 |
Runtime error |
8 ms |
7000 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |