#include "game.h"
#include <bits/stdc++.h>
using namespace std;
long long tree[11][400005];
int n, m;
long long nzd(long long a, long long b) {
if (b==0) return a;
return nzd(b, a%b);
}
void updateST(int k, int left, int right, int red, int kol, long long br) {
if (left==right) {
if (left==kol)
tree[red][k]=br;
return;
}
if (left>right||right<kol||left>kol)
return;
int mid=(left+right)/2;
updateST(2*k, left, mid, red, kol, br);
updateST(2*k+1, mid+1, right, red, kol, br);
tree[red][k]=nzd(tree[red][2*k], tree[red][2*k+1]);
}
long long queryST(int k, int left, int right, int red, int l, int r) {
if (left>right||left>r||l>right)
return 0;
if (l<=left&&right<=r)
return tree[red][k];
int mid=(left+right)/2;
int r1=queryST(2*k, left, mid, red, l, r);
int r2=queryST(2*k+1, mid+1, right, red, l, r);
return nzd(r1, r2);
}
vector<vector<long long> > mat;
void init(int r, int c) {
mat.resize(r, vector<long long> (c, 0));
n=r, m=c;
}
void update(int r, int c, long long br) {
mat[r][c]=br;
updateST(1, 0, m-1, r, c, br);
}
long long calculate(int x1, int y1, int x2, int y2) {
long long rez=mat[x1][y1];
for (int i=x1;i<=x2;i++)
rez=nzd(rez, queryST(1, 0, m-1, i, y1, y2));
return rez;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
860 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
612 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
360 KB |
Output is correct |
2 |
Runtime error |
1 ms |
740 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
2 ms |
692 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |