Submission #254221

# Submission time Handle Problem Language Result Execution time Memory
254221 2020-07-29T14:47:54 Z AaronNaidu Game (IOI13_game) C++14
27 / 100
725 ms 39780 KB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;
typedef long long ll;

int r, c, p, q, u, v;
ll segTree[32][262144];

void init(int R, int C) {
    r = R;
    c = C;
}

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;
}

void update(int p, int q, ll k) {
    p += 16;
    q += 131072;
    segTree[p][q] = k;
    while (q > 0)
    {
        //cout << "Outerwhile q = " << q << "\n";
        int pTemp = p/2;
        while (pTemp > 0)
        {
            //cout <<"Innerwhile p temp = " << pTemp << "\n";
            segTree[pTemp][q] = gcd2(segTree[2*pTemp][q], segTree[2*pTemp+1][q]);
            pTemp /= 2;
        }
        q /= 2;
        segTree[p][q] = gcd2(segTree[p][2*q], segTree[p][2*q+1]);
        //cout << "End of outerwhile q = " << q << "\n";
    }

}

ll getSegTree(int nodex, int nodey, int nodexstart, int nodexend, int nodeystart, int nodeyend) {
    if (nodexstart > u or nodexend < p or nodeystart > v or nodeyend < q)
    {
        return 0;
    }
    if (nodexstart >= p and nodexend <= u)
    {
        if (nodeystart >= q and nodeyend <= v)
        {
            return segTree[nodex][nodey];
        }
        int midy = (nodeystart + nodeyend)/2;
        return gcd2(getSegTree(nodex, 2*nodey, nodexstart, nodexend, nodeystart, midy), getSegTree(nodex, 2*nodey+1, nodexstart, nodexend, midy+1, nodeyend));
    }
    int midx = (nodexstart + nodexend)/2;
    return gcd2(getSegTree(2*nodex, nodey, nodexstart, midx, nodeystart, nodeyend), getSegTree(2*nodex+1, nodey, midx + 1, nodexend, nodeystart, nodeyend));
}    
    
ll calculate(int P, int Q, int U, int V) {
    p = P;
    q = Q;
    u = U;
    v = V;
    return getSegTree(1, 1, 0, 15, 0, 131071);
}

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;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 640 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 691 ms 36264 KB Output is correct
5 Correct 536 ms 39344 KB Output is correct
6 Correct 725 ms 39780 KB Output is correct
7 Correct 715 ms 39544 KB Output is correct
8 Correct 634 ms 39160 KB Output is correct
9 Correct 693 ms 39604 KB Output is correct
10 Correct 662 ms 39220 KB Output is correct
11 Correct 1 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Runtime error 4 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 640 KB Output is correct
2 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -