답안 #1090302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090302 2024-09-18T08:12:09 Z vjudge1 게임 (IOI13_game) C++17
37 / 100
13000 ms 37280 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct SegTree {
    int n;
    vector<ll> tree;

    void init(int _n) { n = _n; tree.resize(4*_n); }

    void update(int u, int tl, int tr, int p, ll v) {
        if(tl == tr) {
            tree[u] = v;
        } else {
            int tm = (tl + tr) / 2;
            if(p <= tm) update(2*u, tl, tm, p, v);
            else update(2*u+1, tm+1, tr, p, v);
            tree[u] = gcd(tree[2*u], tree[2*u+1]);
        }
    }

    ll query(int u, int tl, int tr, int l, int r) {
        if(l > tr || tl > r || !tree[u]) return 0;
        if(l <= tl && tr <= r) return tree[u];
        int tm = (tl + tr) / 2;
        return gcd(query(2*u, tl, tm, l, r), query(2*u+1, tm+1, tr, l, r));
    }

    void update(int p, ll v) { update(1, 0, n-1, p, v); }
    ll query(int l, int r) { return query(1, 0, n-1, l, r); }
};

vector<SegTree> tree;

void init(int R, int C) {
    tree.resize(R);
    for(int i=0; i<R; i++) tree[i].init(C);
}

void update(int P, int Q, ll K) {
    tree[P].update(Q, K);
}

ll calculate(int P, int Q, int U, int V) {
    ll ans = 0;
    for(int i=P; i<=U; i++) ans = gcd(ans, tree[i].query(Q, V));
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
8 Correct 0 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 0 ms 604 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 401 ms 35584 KB Output is correct
5 Correct 255 ms 36028 KB Output is correct
6 Correct 317 ms 32696 KB Output is correct
7 Correct 335 ms 32340 KB Output is correct
8 Correct 247 ms 33364 KB Output is correct
9 Correct 327 ms 32596 KB Output is correct
10 Correct 296 ms 32084 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 10173 ms 37232 KB Output is correct
13 Execution timed out 13020 ms 34384 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 397 ms 35804 KB Output is correct
13 Correct 228 ms 35924 KB Output is correct
14 Correct 305 ms 32652 KB Output is correct
15 Correct 347 ms 32336 KB Output is correct
16 Correct 240 ms 33364 KB Output is correct
17 Correct 326 ms 32592 KB Output is correct
18 Correct 287 ms 32076 KB Output is correct
19 Correct 10034 ms 37280 KB Output is correct
20 Execution timed out 13018 ms 34592 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 344 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 383 ms 35672 KB Output is correct
13 Correct 241 ms 35944 KB Output is correct
14 Correct 337 ms 32848 KB Output is correct
15 Correct 378 ms 32420 KB Output is correct
16 Correct 248 ms 33360 KB Output is correct
17 Correct 335 ms 32592 KB Output is correct
18 Correct 289 ms 32084 KB Output is correct
19 Correct 10116 ms 37200 KB Output is correct
20 Execution timed out 13067 ms 34588 KB Time limit exceeded
21 Halted 0 ms 0 KB -