답안 #1090459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090459 2024-09-18T11:43:30 Z vjudge1 게임 (IOI13_game) C++17
0 / 100
1 ms 1124 KB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define int long long

#define ar array
struct Seggy{
    vector<ll> s;

    void init(int n){
        s.resize(3 * n, 0);
    }

    void upd(int k,int tl,int tr,int p,ll v){
        if(tl == tr){
            s[k] = v;
            return;
        }
        int tm = (tl + tr) / 2;
        if(p <= tm)upd(k *2, tl, tm, p, v);
        else upd(k *2 + 1, tm + 1, tr, p, v);
        s[k] = __gcd(s[k * 2], s[k * 2 + 1]);
    }

    ll qry(int k,int tl,int tr,int l,int r){
        if(l > tr || tl > r)return 0;
        if(l <= tl && tr <= r)return s[k];
        int tm = (tl +tr) / 2;
        return __gcd(qry(k * 2,tl, tm, l, r), qry(k *2 + 1, tm + 1, tr, l, r));
    }
};

namespace Seggy2D{
    vector<Seggy> seg;
    int n, m;
    void init(int _n,int _m){
        n = _n, m = _m;
        seg.resize(3 * n);
        for(auto &u: seg)u.init(m);
    }

    void upd(int k,int tl,int tr,int p, ar<int, 2> v){
        if(tl != tr){
            int tm = (tl + tr) / 2;
            if(p <= tm)upd(k * 2, tl, tm, p, v);
            else upd(k * 2 + 1, tm + 1, tr, p, v);
        }
        seg[k].upd(1, 0, m - 1, v[0], v[1]);
    }

    int qry(int k,int tl,int tr, int l,int r, ar<int, 2> v){
        if(l > tr || tl > r)return 0;
        if(l <= tl && tr <= r)return seg[k].qry(1,0 ,m - 1, v[0], v[1]);
        int tm = (tl + tr) / 2;
        return __gcd(qry(k *2 ,tl, tm, l, r, v), qry(k *2 + 1, tm + 1, tr , l,r ,v ));
    }
};


int n, m;

void init(signed R, signed C) {
    n = R, m = C;
    Seggy2D::init(R, C);
}

void update(signed P, signed Q, long long K) {
    Seggy2D::upd(1, 0, n - 1, P, {Q, K});
}

long long calculate(signed P, signed Q, signed U, signed V) {
    return Seggy2D::qry(1, 0, n - 1, P, U, {Q, V});
}
#define int signed

Compilation message

game.cpp:77: warning: "int" redefined
   77 | #define int signed
      | 
game.cpp:7: note: this is the location of the previous definition
    7 | #define int long long
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Incorrect 1 ms 1124 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 356 KB Output is correct
2 Incorrect 0 ms 436 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -