Submission #1090955

# Submission time Handle Problem Language Result Execution time Memory
1090955 2024-09-19T08:49:44 Z RiverFlow Game (IOI13_game) C++14
27 / 100
502 ms 40016 KB
#include "game.h"
#include <bits/stdc++.h>

#define nl "\n"
#define no "NO"
#define yes "YES"
#define fi first
#define se second
#define vec vector
#define task "main"
#define _mp make_pair
#define ii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define evoid(val) return void(std::cout << val)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FOD(i, b, a) for(int i = (b); i >= (a); --i)
#define unq(x) sort(all(x)); x.resize(unique(all(x)) - x.begin())

using namespace std;

template<typename U, typename V> bool maxi(U &a, V b) {
    if (a < b) { a = b; return 1; } return 0;
}
template<typename U, typename V> bool mini(U &a, V b) {
    if (a > b) { a = b; return 1; } return 0;
}

const int N = (int)2e5 + 9;
const int mod = (int)1e9 + 7;

struct IT {
    int n;
    vec<long long> t;
    IT () {};
    IT (int _n) {
        n = _n;
        t.resize(4 * n + 7);
    }
    void upd(int id, int l, int r, int p, long long v) {
        if (l == r)
            return void(t[id] = v);
        int m = (l + r) >> 1;
        if (p <= m) upd(id << 1, l, m, p, v);
        else        upd(id << 1 | 1, m + 1, r, p, v);
        t[id] = __gcd(t[id << 1], t[id << 1 | 1]);
    }
    long long get(int id, int l, int r, int u, int v) {
        if (l > v or r < u) return 0;
        if (l >= u and r <= v) return t[id];
        int m = (l + r) >> 1;
        return __gcd(get(id << 1, l, m, u, v),
                     get(id << 1 | 1, m + 1, r, u, v));
    }
};
namespace SUB2 {
    int n, m;
    IT st[10];
    void init(int _n, int _m) {
        n = _n;
        m = _m;
        FOR(i, 0, n - 1)
            st[i] = IT(m);
    }
    void upd(int x, int y, long long k) {
        ++y;
        st[x].upd(1, 1, m, y, k);
    }
    long long query(int x, int y, int u, int v) {
        ++y, ++v;
        long long ans = 0;
        for(int i = x; i <= u; ++i) {
            ans = __gcd(ans, st[i].get(1, 1, m, y, v));
        }
        return ans;
    }
};


int n, m;

bool sub2 = 0;

void init(int R, int C) {
    n = R, m = C;
    if (n <= 10 and m <= (int)1e5) {
        sub2 = 1;
        SUB2::init(n, m);
    }
}

void update(int P, int Q, long long K) {
    if (sub2) {
        SUB2::upd(P, Q, K);
        return ;
    }
}

long long calculate(int P, int Q, int U, int V) {
    if (sub2) {
        return SUB2::query(P, Q, U, V);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 502 ms 40012 KB Output is correct
5 Correct 324 ms 40016 KB Output is correct
6 Correct 426 ms 37524 KB Output is correct
7 Correct 427 ms 37012 KB Output is correct
8 Correct 365 ms 37464 KB Output is correct
9 Correct 419 ms 37204 KB Output is correct
10 Correct 351 ms 36688 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 436 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 432 KB Output isn't correct
3 Halted 0 ms 0 KB -