Submission #1090494

# Submission time Handle Problem Language Result Execution time Memory
1090494 2024-09-18T12:08:22 Z vjudge1 Game (IOI13_game) C++17
37 / 100
13000 ms 43376 KB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

vector<long long> tree[2005];
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;
    long long r1=queryST(2*k, left, mid, red, l, r);
    long long r2=queryST(2*k+1, mid+1, right, red, l, r);
    return nzd(r1, r2);
}


void init(int r, int c) {
    for (int i=0;i<=r;i++) 
        tree[i].assign(4*c, 0);
    n=r, m=c;
} 

void update(int r, int c, long long br) {
    updateST(1, 0, m-1, r, c, br);
}

long long calculate(int x1, int y1, int x2, int y2) {
    long long rez=0;
    for (int i=x1;i<=x2;i++)
        rez=nzd(rez, queryST(1, 0, m-1, i, y1, y2));
    return rez;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 740 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 0 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 484 KB Output is correct
4 Correct 667 ms 43376 KB Output is correct
5 Correct 448 ms 43092 KB Output is correct
6 Correct 507 ms 40444 KB Output is correct
7 Correct 500 ms 40328 KB Output is correct
8 Correct 434 ms 40748 KB Output is correct
9 Correct 510 ms 40272 KB Output is correct
10 Correct 438 ms 40016 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 488 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Execution timed out 13091 ms 34780 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 596 ms 43180 KB Output is correct
13 Correct 406 ms 43004 KB Output is correct
14 Correct 466 ms 40528 KB Output is correct
15 Correct 452 ms 40276 KB Output is correct
16 Correct 474 ms 40788 KB Output is correct
17 Correct 604 ms 40276 KB Output is correct
18 Correct 450 ms 40020 KB Output is correct
19 Execution timed out 13068 ms 34756 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 604 ms 43200 KB Output is correct
13 Correct 412 ms 43088 KB Output is correct
14 Correct 460 ms 40528 KB Output is correct
15 Correct 464 ms 40248 KB Output is correct
16 Correct 390 ms 40788 KB Output is correct
17 Correct 473 ms 40244 KB Output is correct
18 Correct 391 ms 40020 KB Output is correct
19 Execution timed out 13061 ms 34580 KB Time limit exceeded
20 Halted 0 ms 0 KB -