This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
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;
}
static long long tree[4005][4005];
int N, M;
void init(int R, int C) {
N = R; M = C;
for(int i = 1;i <= 2 * R;i++){
for(int j = 1;j <= 2 * C;j++){
tree[i][j] = 0;
}
}
}
void update(int r, int c, long long v) {
int nr = N + r;
int nc = M + c;
tree[nr][nc] = v;
while(nr > 0){
nc = M + c;
while(nc > 0){
if(nr < N){
tree[nr][nc] = gcd2(tree[nr<<1][nc],tree[nr<<1|1][nc]);
}
else if(nc < M){
tree[nr][nc] = gcd2(tree[nr][nc<<1],tree[nr][nc<<1|1]);
}
else tree[nr][nc] = v;
//cout << nr << " " << nc << "\n";
nc >>= 1;
}
nr >>= 1;
}
//cout << endl;
}
long long calculate(int t, int l, int b, int r) {
long long ans = 0;
b++; r++;
for(t += N, b += N;t < b;t >>= 1, b >>= 1){
if(t&1){
for(int nl = l+M, nr = r+M;nl < nr;nr >>= 1, nl >>= 1){
if(nl&1){
ans = gcd2(ans, tree[t][nl]);
//cout << t << " " << nl << "\n";
nl++;
}
if(nr&1){
nr--;
ans = gcd2(ans, tree[t][nr]);
//cout << t << " " << nr << "\n";
}
}
t++;
}
if(b&1){
b--;
for(int nl = l+M, nr = r+M;nl < nr;nr >>= 1, nl >>= 1){
if(nl&1){
ans = gcd2(ans, tree[b][nl]);
//cout << b << " " << nl << "\n";
nl++;
}
if(nr&1){
nr--;
ans = gcd2(ans, tree[b][nr]);
//cout << b << " " << nr << "\n";
}
}
}
}
//cout << endl;
return ans;
}
Compilation message (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |