답안 #290061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290061 2020-09-03T10:56:48 Z egekabas 게임 (IOI13_game) C++14
63 / 100
2402 ms 256004 KB
#include "game.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<ll, ll> pii;
typedef pair<ld, ld> pld;
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;
}
ll r, c, rr;

struct node{
    int tl, tr;
    ll val;
    node *l = nullptr, *r = nullptr;
    node(ll tlval, ll trval){
        tl = tlval;
        tr = trval;
        val = 0;
    }
    node(){
        tl = tr = val = -1;
    }   
    void upd(ll idx, ll nv){
        if(tl == idx && tr == idx){
            val = nv;
            return;
        }
        ll tm = (tl+tr)/2;
        if(idx <= tm){
            if(!l)
                l = new node(tl, tm);
            l->upd(idx, nv);
        }
        else{
            if(!r)
                r = new node(tm+1, tr);
            r->upd(idx, nv);
        }
        ll xval = 0, yval = 0;
        if(l)
            xval =  l->val;
        if(r)
            yval = r->val;
        val = gcd2(xval, yval);        
    }
    ll get(ll lef, ll rig){
        
        if(tr < lef || rig < tl)
            return 0;
        if(lef <= tl && tr <= rig){
            return val;
        }
        ll xval = 0, yval = 0;
        if(l)
            xval = l->get(lef, rig);
        if(r)
            yval = r->get(lef, rig);
        return gcd2(xval, yval);
    }
};
struct seg{
    int tl, tr;
    node *val;
    seg *l = nullptr, *r = nullptr;
    map<int, node> v;
    seg(ll tval, ll rval){
        tl = tval;
        tr = rval;
        val = new node(0, c-1);
    }
    seg(){}
    void upd(ll xidx, ll yidx, ll nv){    
        if(xidx < tl || xidx > tr) return;
        if(v[yidx].tl == -1)
            v[yidx] = node(tl, tr);
        v[yidx].upd(xidx, nv);
        val->upd(yidx, v[yidx].val);
        if(tl == tr){
            return;
        }
        ll tm = (tl+tr)/2;
        if(xidx <= tm){
            if(!l)
                l = new seg(tl, tm);
            l->upd(xidx, yidx, nv);
        }
        else{
            if(!r)
                r = new seg(tm+1, tr);
            r->upd(xidx, yidx, nv);
        }
    }
    ll get(int xl, int xr, int yl, int yr){
        if(tr < xl || xr < tl)
            return 0;
        if(xl <= tl && tr <= xr){
            return val->get(yl, yr);
        }
        ll xval = 0, yval = 0;
        if(l)
            xval = l->get(xl, xr, yl, yr);
        if(r)
            yval = r->get(xl, xr, yl, yr);
        return gcd2(xval, yval);
    }
};
seg root;
void init(int R, int C) {
    r = rr = R;
    c = C;
    root = seg(0, r-1);
}
    
void update(int P, int Q, long long K) {
    root.upd(P, Q, K);
}
    
long long calculate(int P, int Q, int U, int V){    
    return root.get(P, U, Q, V);
}

Compilation message

grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   18 |  int res;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 640 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 794 ms 24304 KB Output is correct
5 Correct 485 ms 24452 KB Output is correct
6 Correct 696 ms 21752 KB Output is correct
7 Correct 803 ms 21516 KB Output is correct
8 Correct 479 ms 12920 KB Output is correct
9 Correct 809 ms 21496 KB Output is correct
10 Correct 757 ms 20984 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 640 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 1214 ms 51508 KB Output is correct
13 Correct 1655 ms 25924 KB Output is correct
14 Correct 353 ms 1784 KB Output is correct
15 Correct 1953 ms 35248 KB Output is correct
16 Correct 394 ms 63996 KB Output is correct
17 Correct 1339 ms 35380 KB Output is correct
18 Correct 2360 ms 64584 KB Output is correct
19 Correct 2070 ms 64888 KB Output is correct
20 Correct 1998 ms 64120 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 640 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 734 ms 24260 KB Output is correct
13 Correct 497 ms 24436 KB Output is correct
14 Correct 701 ms 21624 KB Output is correct
15 Correct 800 ms 21496 KB Output is correct
16 Correct 483 ms 12920 KB Output is correct
17 Correct 771 ms 21532 KB Output is correct
18 Correct 758 ms 21112 KB Output is correct
19 Correct 1194 ms 51224 KB Output is correct
20 Correct 1623 ms 25928 KB Output is correct
21 Correct 347 ms 1912 KB Output is correct
22 Correct 1945 ms 35224 KB Output is correct
23 Correct 384 ms 64120 KB Output is correct
24 Correct 1350 ms 35388 KB Output is correct
25 Correct 2402 ms 64760 KB Output is correct
26 Correct 2061 ms 64692 KB Output is correct
27 Correct 1978 ms 63992 KB Output is correct
28 Runtime error 596 ms 256004 KB Execution killed with signal 9
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 640 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 751 ms 23884 KB Output is correct
13 Correct 502 ms 23928 KB Output is correct
14 Correct 686 ms 21108 KB Output is correct
15 Correct 816 ms 20964 KB Output is correct
16 Correct 480 ms 12400 KB Output is correct
17 Correct 779 ms 21240 KB Output is correct
18 Correct 749 ms 20728 KB Output is correct
19 Correct 1211 ms 50936 KB Output is correct
20 Correct 1633 ms 25720 KB Output is correct
21 Correct 353 ms 1656 KB Output is correct
22 Correct 1970 ms 35044 KB Output is correct
23 Correct 394 ms 63736 KB Output is correct
24 Correct 1337 ms 34884 KB Output is correct
25 Correct 2373 ms 64364 KB Output is correct
26 Correct 2013 ms 64248 KB Output is correct
27 Correct 1978 ms 63720 KB Output is correct
28 Runtime error 572 ms 256004 KB Execution killed with signal 9
29 Halted 0 ms 0 KB -