#include "game.h"
//Billions of bilious blue blistering barnacles in a thundering typhoon!
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
#pragma GCC target("avx2,fma")
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0) , cin.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define str string
#define mdx ((sx + ex) / 2)
#define mdy ((sy + ey) / 2)
#define mid ((l + r) / 2)
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
#define C continue
#define R return
#define B break
#define lxx nodex * 2
#define rxx nodex * 2 + 1
#define lxy nodey * 2
#define rxy nodey * 2 + 1
#define br(dosomething) {dosomething; break;}
#define co(dosomething) {dosomething ; continue;}
using namespace std;
typedef long long ll;
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;
}
ll n , m , k ;
void init(int r, int c) {
n = r , m = c ;
k = 1 ;
}
struct op{
int leftx , rightx , lefty , righty ;
ll val ;
}tree[10000005];
deque < ll > se ;
void updatey(ll sy , ll ey , ll node , ll sx , ll ex , ll x , ll y , ll val){
if(sy == ey){
if(sx == ex){
tree[node].val = val ;
}
else {
ll op = se.front() ;
se.pop_front() ;
if(x <= mdx){
if(!tree[node].leftx)tree[node].leftx = op ;
}
else {
if(!tree[node].rightx)tree[node].rightx = op ;
}
tree[node].val = gcd2(tree[tree[node].leftx].val , tree[tree[node].rightx].val) ;
}
se.pb(node) ;
R ;
}
if(y <= mdy){
if(!tree[node].lefty){
tree[node].lefty = ++k ;
}
updatey(sy , mdy , tree[node].lefty , sx , ex , x , y , val) ;
}
else {
if(!tree[node].righty)tree[node].righty = ++k ;
updatey(mdy + 1 , ey , tree[node].righty , sx , ex , x , y , val) ;
}
tree[node].val = gcd2(tree[tree[node].lefty].val , tree[tree[node].righty].val) ;
}
void updatex(ll sx , ll ex , ll node , ll x , ll y , ll val){
if(sx != ex){
if(x <= mdx){
if(!tree[node].leftx)tree[node].leftx = ++k ;
updatex(sx , mdx , tree[node].leftx , x , y , val) ;
}
else {
if(!tree[node].rightx)tree[node].rightx = ++k ;
updatex(mdx + 1 , ex , tree[node].rightx , x , y , val) ;
}
}
updatey(0 , m - 1 , node , sx , ex , x , y , val) ;
}
ll queryy(ll sy , ll ey , ll node , ll ly , ll ry){
if(sy > ry || ey < ly || !node)R 0 ;
if(ly <= sy && ey <= ry)R tree[node].val ;
R gcd2(queryy(sy , mdy , tree[node].lefty , ly , ry) , queryy(mdy + 1 , ey , tree[node].righty , ly , ry)) ;
}
ll queryx(ll sx , ll ex , ll node , ll lx , ll ly , ll rx , ll ry){
if(sx > rx || ex < lx || !node)R 0 ;
if(lx <= sx && ex <= rx){
R queryy(0 , m - 1 , node , ly , ry) ;
}
R gcd2(queryx(sx , mdx , tree[node].leftx , lx , ly , rx , ry) , queryx(mdx + 1 , ex , tree[node].rightx , lx , ly , rx , ry)) ;
}
void update(int P, int Q, long long K) {
updatex(0 , n - 1 , 1 , P , Q , K) ;
se.clear() ;
}
long long calculate(int P, int Q, int U, int V) {
R queryx(0 , n - 1 , 1 , P , Q , U , V) ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
472 ms |
11020 KB |
Output is correct |
5 |
Correct |
299 ms |
11148 KB |
Output is correct |
6 |
Correct |
407 ms |
8216 KB |
Output is correct |
7 |
Correct |
465 ms |
7804 KB |
Output is correct |
8 |
Correct |
305 ms |
5652 KB |
Output is correct |
9 |
Correct |
432 ms |
8164 KB |
Output is correct |
10 |
Correct |
422 ms |
7624 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
1 ms |
312 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
756 ms |
13128 KB |
Output is correct |
13 |
Correct |
1321 ms |
5332 KB |
Output is correct |
14 |
Correct |
250 ms |
1336 KB |
Output is correct |
15 |
Correct |
1502 ms |
7228 KB |
Output is correct |
16 |
Correct |
171 ms |
14388 KB |
Output is correct |
17 |
Correct |
638 ms |
9416 KB |
Output is correct |
18 |
Correct |
1081 ms |
17308 KB |
Output is correct |
19 |
Correct |
950 ms |
17488 KB |
Output is correct |
20 |
Correct |
872 ms |
16848 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
460 ms |
10832 KB |
Output is correct |
13 |
Correct |
302 ms |
11144 KB |
Output is correct |
14 |
Correct |
413 ms |
7752 KB |
Output is correct |
15 |
Correct |
462 ms |
7420 KB |
Output is correct |
16 |
Correct |
309 ms |
5496 KB |
Output is correct |
17 |
Correct |
417 ms |
7556 KB |
Output is correct |
18 |
Correct |
389 ms |
7172 KB |
Output is correct |
19 |
Correct |
671 ms |
12844 KB |
Output is correct |
20 |
Correct |
1274 ms |
4888 KB |
Output is correct |
21 |
Correct |
287 ms |
1036 KB |
Output is correct |
22 |
Correct |
1469 ms |
6884 KB |
Output is correct |
23 |
Correct |
164 ms |
13868 KB |
Output is correct |
24 |
Correct |
707 ms |
9024 KB |
Output is correct |
25 |
Correct |
1106 ms |
19560 KB |
Output is correct |
26 |
Correct |
982 ms |
19600 KB |
Output is correct |
27 |
Correct |
920 ms |
18916 KB |
Output is correct |
28 |
Correct |
590 ms |
195440 KB |
Output is correct |
29 |
Correct |
1344 ms |
215980 KB |
Output is correct |
30 |
Correct |
3599 ms |
157560 KB |
Output is correct |
31 |
Correct |
3433 ms |
121900 KB |
Output is correct |
32 |
Correct |
470 ms |
10228 KB |
Output is correct |
33 |
Correct |
602 ms |
12084 KB |
Output is correct |
34 |
Correct |
408 ms |
209696 KB |
Output is correct |
35 |
Correct |
1045 ms |
112692 KB |
Output is correct |
36 |
Correct |
1797 ms |
214140 KB |
Output is correct |
37 |
Correct |
1654 ms |
214184 KB |
Output is correct |
38 |
Correct |
1531 ms |
213552 KB |
Output is correct |
39 |
Correct |
1292 ms |
166456 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
432 ms |
10532 KB |
Output is correct |
13 |
Correct |
300 ms |
11044 KB |
Output is correct |
14 |
Correct |
376 ms |
7848 KB |
Output is correct |
15 |
Correct |
453 ms |
7456 KB |
Output is correct |
16 |
Correct |
315 ms |
5664 KB |
Output is correct |
17 |
Correct |
419 ms |
7776 KB |
Output is correct |
18 |
Correct |
407 ms |
7168 KB |
Output is correct |
19 |
Correct |
708 ms |
12844 KB |
Output is correct |
20 |
Correct |
1208 ms |
4800 KB |
Output is correct |
21 |
Correct |
263 ms |
908 KB |
Output is correct |
22 |
Correct |
1461 ms |
6708 KB |
Output is correct |
23 |
Correct |
163 ms |
13748 KB |
Output is correct |
24 |
Correct |
688 ms |
8872 KB |
Output is correct |
25 |
Correct |
1080 ms |
19456 KB |
Output is correct |
26 |
Correct |
897 ms |
19508 KB |
Output is correct |
27 |
Correct |
813 ms |
19032 KB |
Output is correct |
28 |
Correct |
597 ms |
195260 KB |
Output is correct |
29 |
Correct |
1328 ms |
215968 KB |
Output is correct |
30 |
Correct |
3481 ms |
157468 KB |
Output is correct |
31 |
Correct |
3354 ms |
121980 KB |
Output is correct |
32 |
Correct |
454 ms |
10304 KB |
Output is correct |
33 |
Correct |
601 ms |
12300 KB |
Output is correct |
34 |
Correct |
395 ms |
209744 KB |
Output is correct |
35 |
Correct |
952 ms |
112688 KB |
Output is correct |
36 |
Correct |
1819 ms |
214160 KB |
Output is correct |
37 |
Correct |
1516 ms |
214156 KB |
Output is correct |
38 |
Correct |
1469 ms |
213424 KB |
Output is correct |
39 |
Runtime error |
744 ms |
256000 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |