답안 #54515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54515 2018-07-03T22:59:08 Z KieranHorgan 게임 (IOI13_game) C++17
0 / 100
3 ms 516 KB
#pragma GCC optimize("Ofast")
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
long long gcd2(long long X, long long Y) {
    long long tmp;
    if(X==0&&Y==0) return 0;
    if(X==0) return Y;
    if(Y==0) return X;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}
 
int R, C;
struct colNode {
    int l, r, st;
    colNode *left, *right;
    colNode(int lv, int rv): left(NULL), right(NULL), st(0) {l=lv; r=rv;};
};
set<pair<int, int>> isNew;
void update(int j, int val, colNode *cur) {
    if(cur == NULL) return;
    if(j < cur->l || j >= cur->r) return;
    if(cur->l + 1 == cur->r) {
        cur->st = val;
        // cerr << cur->l << " " << cur->r << ":    \t" << cur->st << endl;
        //Check if merging rows
        return;
    }
    int mid = (cur->l + cur->r)/2;
    if(j < mid) {
        if(cur->left == NULL)
            cur->left = new colNode(cur->l, mid);
        update(j, val, cur->left);
    } else {
        if(cur->right == NULL)
            cur->right = new colNode(mid, cur->r);
        update(j, val, cur->right);
    }
}
int query(int x, int y, colNode *cur) {
    if(x >= cur->r || y <= cur->l) return 0;
    if(y >= cur->r && x <= cur->l)
        return cur->st;
    if(cur->right==NULL) return query(x, y, cur->left);
    if(cur->left==NULL) return query(x, y, cur->right);
    return gcd2(query(x, y, cur->left),
                query(x, y, cur->right));
}
struct rowNode {
    int l, r, st;
    rowNode *left, *right;
    colNode *col;
    rowNode(int lv, int rv): left(NULL), right(NULL), st(0) {l=lv; r=rv; col = new colNode(0, C);};
};
void update(int i, int j, int val, rowNode *cur) {
    if(cur == NULL) return;
    if(i < cur->l || i >= cur->r) return;
    int mid = (cur->l + cur->r)/2;
    
    if(j==cur->l && j+1==cur->r);
    else if(j < mid) {
        if(cur->left == NULL)
            cur->left = new rowNode(cur->l, mid);
        update(i, j, val, cur->left);
    } else {
        if(cur->right == NULL)
            cur->right = new rowNode(mid, cur->r);
        update(i, j, val, cur->right);
    }
    update(j, val, cur->col);
        // cerr << cur->l << " " << cur->r << ":    \t" << cur->st << endl;
}
int query(int x, int y, int nx, int ny, rowNode *cur) {
    if(x >= cur->r || y <= cur->l) return 0;
    if(y >= cur->r && x <= cur->l)
        return query(nx, ny, cur->col);
    if(cur->right==NULL) return query(x, y, nx, ny, cur->left);
    if(cur->left==NULL) return query(x, y, nx, ny, cur->right);
    return gcd2(query(x, y, nx, ny, cur->left),
                query(x, y, nx, ny, cur->right));
}

rowNode root(0,1);

void init(signed r, signed c) {
    R = r;
    C = c;
    root.l = 0; root.r=R;
}

void update(signed P, signed Q, long long K) {
    // cerr << "Update:" << endl;
    update(P, Q, K, &root);
    // cerr << endl;
    // update(Q, K, &root);
    // cerr << endl;
    // tree.update(K, P, Q);
}
 
long long calculate(signed P, signed Q, signed U, signed V) {
    // return tree.query(P, U+1, Q, V+1);
    // cerr << "Query:" << endl;
    // int x = query(P, U+1, Q, V+1, &root);
    // cerr << endl;
    // cerr << endl;
    return 0;
}

Compilation message

grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
game.cpp: In constructor 'colNode::colNode(long long int, long long int)':
game.cpp:23:21: warning: 'colNode::right' will be initialized after [-Wreorder]
     colNode *left, *right;
                     ^~~~~
game.cpp:22:15: warning:   'long long int colNode::st' [-Wreorder]
     int l, r, st;
               ^~
game.cpp:24:5: warning:   when initialized here [-Wreorder]
     colNode(int lv, int rv): left(NULL), right(NULL), st(0) {l=lv; r=rv;};
     ^~~~~~~
game.cpp: In constructor 'rowNode::rowNode(long long int, long long int)':
game.cpp:58:21: warning: 'rowNode::right' will be initialized after [-Wreorder]
     rowNode *left, *right;
                     ^~~~~
game.cpp:57:15: warning:   'long long int rowNode::st' [-Wreorder]
     int l, r, st;
               ^~
game.cpp:60:5: warning:   when initialized here [-Wreorder]
     rowNode(int lv, int rv): left(NULL), right(NULL), st(0) {l=lv; r=rv; col = new colNode(0, C);};
     ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 516 KB Output isn't correct
2 Halted 0 ms 0 KB -