#include<bits/stdc++.h>
#include "game.h"
using namespace std;
long long my_gcd(long long a,long long b)
{
if(a==0||b==0)return a+b;
long long r=a%b;
while(r)
{
a=b;
b=r;
r=a%b;
}
return b;
}
const int rmax=1e2+5,cmax=262144+42;
long long tree[rmax][cmax];
int r,c;
void init(int R, int C)
{
r=R;
c=C;
}
void my_update(int ind,int node,int l,int r,int pos,long long val)
{
if(l==r)
{
tree[ind][node]=val;
return;
}
int av=(l+r)/2;
if(pos<=av)my_update(ind,node*2,l,av,pos,val);
else my_update(ind,node*2+1,av+1,r,pos,val);
tree[ind][node]=my_gcd(tree[ind][node*2],tree[ind][node*2+1]);
}
void update(int P, int Q, long long K)
{
my_update(P,1,0,c-1,Q,K);
}
long long my_query(int ind,int node,int l,int r,int lq,int rq)
{
if(tree[ind][node]==0)return tree[ind][node];
if(l==lq&&r==rq)return tree[ind][node];
int av=(l+r)/2;
long long ans=0;
if(lq<=av)ans=my_gcd(ans,my_query(ind,node*2,l,av,lq,min(av,rq)));
if(av<rq)ans=my_gcd(ans,my_query(ind,node*2+1,av+1,r,max(av+1,lq),rq));
return ans;
}
long long calculate(int P, int Q, int U, int V)
{
long long ans=0;
for(int i=P;i<=U;i++)
ans=my_gcd(ans,my_query(i,1,0,c-1,Q,V));
return ans;
}
/*
int main()
{
init(2,3);
update(0,0,20);
update(0,2,15);
update(1,1,12);
cout<<calculate(0,0,0,2)<<endl;//5
cout<<calculate(0,0,1,1)<<endl;//4
update(0,1,6);
update(1,1,14);
cout<<calculate(0,0,0,2)<<endl;//1
cout<<calculate(0,0,1,1)<<endl;//2
}
*/
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 |
Correct |
4 ms |
1212 KB |
Output is correct |
3 |
Correct |
4 ms |
1212 KB |
Output is correct |
4 |
Correct |
2 ms |
1212 KB |
Output is correct |
5 |
Correct |
3 ms |
1212 KB |
Output is correct |
6 |
Correct |
3 ms |
1212 KB |
Output is correct |
7 |
Correct |
2 ms |
1212 KB |
Output is correct |
8 |
Correct |
3 ms |
1212 KB |
Output is correct |
9 |
Correct |
4 ms |
1308 KB |
Output is correct |
10 |
Correct |
3 ms |
1308 KB |
Output is correct |
11 |
Correct |
2 ms |
1308 KB |
Output is correct |
12 |
Correct |
2 ms |
1308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1308 KB |
Output is correct |
2 |
Correct |
2 ms |
1308 KB |
Output is correct |
3 |
Correct |
2 ms |
1308 KB |
Output is correct |
4 |
Correct |
1158 ms |
25364 KB |
Output is correct |
5 |
Correct |
909 ms |
29792 KB |
Output is correct |
6 |
Correct |
895 ms |
34764 KB |
Output is correct |
7 |
Correct |
1044 ms |
39120 KB |
Output is correct |
8 |
Correct |
663 ms |
41984 KB |
Output is correct |
9 |
Correct |
917 ms |
47988 KB |
Output is correct |
10 |
Correct |
775 ms |
52504 KB |
Output is correct |
11 |
Correct |
2 ms |
52504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
52504 KB |
Output is correct |
2 |
Correct |
4 ms |
52504 KB |
Output is correct |
3 |
Correct |
4 ms |
52504 KB |
Output is correct |
4 |
Correct |
2 ms |
52504 KB |
Output is correct |
5 |
Correct |
3 ms |
52504 KB |
Output is correct |
6 |
Correct |
3 ms |
52504 KB |
Output is correct |
7 |
Correct |
3 ms |
52504 KB |
Output is correct |
8 |
Correct |
5 ms |
52504 KB |
Output is correct |
9 |
Correct |
4 ms |
52504 KB |
Output is correct |
10 |
Correct |
4 ms |
52504 KB |
Output is correct |
11 |
Correct |
3 ms |
52504 KB |
Output is correct |
12 |
Runtime error |
7 ms |
52504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
52504 KB |
Output is correct |
2 |
Correct |
4 ms |
52504 KB |
Output is correct |
3 |
Correct |
4 ms |
52504 KB |
Output is correct |
4 |
Correct |
2 ms |
52504 KB |
Output is correct |
5 |
Correct |
3 ms |
52504 KB |
Output is correct |
6 |
Correct |
25 ms |
52504 KB |
Output is correct |
7 |
Correct |
2 ms |
52504 KB |
Output is correct |
8 |
Correct |
3 ms |
52504 KB |
Output is correct |
9 |
Correct |
3 ms |
52504 KB |
Output is correct |
10 |
Correct |
3 ms |
52504 KB |
Output is correct |
11 |
Correct |
5 ms |
52504 KB |
Output is correct |
12 |
Correct |
1156 ms |
57056 KB |
Output is correct |
13 |
Correct |
894 ms |
61120 KB |
Output is correct |
14 |
Correct |
861 ms |
66204 KB |
Output is correct |
15 |
Correct |
927 ms |
70584 KB |
Output is correct |
16 |
Correct |
598 ms |
73560 KB |
Output is correct |
17 |
Correct |
973 ms |
79552 KB |
Output is correct |
18 |
Correct |
806 ms |
83940 KB |
Output is correct |
19 |
Runtime error |
9 ms |
83940 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
83940 KB |
Output is correct |
2 |
Correct |
4 ms |
83940 KB |
Output is correct |
3 |
Correct |
3 ms |
83940 KB |
Output is correct |
4 |
Correct |
2 ms |
83940 KB |
Output is correct |
5 |
Correct |
4 ms |
83940 KB |
Output is correct |
6 |
Correct |
4 ms |
83940 KB |
Output is correct |
7 |
Correct |
3 ms |
83940 KB |
Output is correct |
8 |
Correct |
5 ms |
83940 KB |
Output is correct |
9 |
Correct |
4 ms |
83940 KB |
Output is correct |
10 |
Correct |
3 ms |
83940 KB |
Output is correct |
11 |
Correct |
2 ms |
83940 KB |
Output is correct |
12 |
Correct |
1165 ms |
88164 KB |
Output is correct |
13 |
Correct |
887 ms |
92468 KB |
Output is correct |
14 |
Correct |
939 ms |
97540 KB |
Output is correct |
15 |
Correct |
1038 ms |
101828 KB |
Output is correct |
16 |
Correct |
618 ms |
104784 KB |
Output is correct |
17 |
Correct |
1000 ms |
110844 KB |
Output is correct |
18 |
Correct |
864 ms |
115176 KB |
Output is correct |
19 |
Runtime error |
9 ms |
115176 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Halted |
0 ms |
0 KB |
- |