제출 #798975

#제출 시각아이디문제언어결과실행 시간메모리
798975alittlemiddle게임 (IOI13_game)C++14
컴파일 에러
0 ms0 KiB
#include "game.h" #include<bits/stdc++.h> int m, n; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int n; struct node1 { int l, r, ss; node1 *left, *right; node1(int _l, int _r) { l = _l; r = _r; ss = 0; left = right = NULL; } void down() { if (l != r && left == NULL) { left = new node1(l, l + r >> 1); right = new node1((l + r >> 1) + 1, r); } } void update(int i, int v) { if (r < i || i < l) return; down(); if (l == r) { ss = v; return; } left->update(i, v); right->update(i, v); ss = gcd(left->ss , right->ss); } int get(int i, int j) { if (r < i || j < l) return 0; down(); if (i <= l && r <= j) return ss; return gcd(left->get(i, j) , right->get(i, j)); } }; struct node2 { int l, r, ss; node2 *left, *right; node1 *node; node2(int _l, int _r) { l = _l; r = _r; ss = 0; left = right = NULL; node = new node1(0, n - 1); } void down() { if (l != r && left == NULL) { left = new node2(l, l + r >> 1); right = new node2((l + r >> 1) + 1, r); } } void update(int x, int y, int val) { if (r < x || x < l) return; down(); node->update(y, val); if (l == r) return; left->update(x, y, val); right->update(x, y, val); } int get(int x, int y, int u, int v) { if (r < x || u < l) return 0; down(); if (x <= l && r <= u) return node->get(y, v); return gcd(left->get(x, y, u, v) , right->get(x, y, u, v)); } }; node2* root; void init(int R, int C) { m = R; n = C; root = new node2(0, R-1); } void update(int P, int Q, long long K) { root->update(P, Q, K); } long long calculate(int P, int Q, int U, int V) { return root->get(P, U, Q, V); }

컴파일 시 표준 에러 (stderr) 메시지

game.cpp:10:5: error: redefinition of 'int n'
   10 | int n;
      |     ^
game.cpp:3:8: note: 'int n' previously declared here
    3 | int m, n;
      |        ^
game.cpp: In member function 'void node1::down()':
game.cpp:29:35: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   29 |             left = new node1(l, l + r >> 1);
      |                                 ~~^~~
game.cpp:30:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |             right = new node1((l + r >> 1) + 1, r);
      |                                ~~^~~
game.cpp: In member function 'void node2::down()':
game.cpp:76:35: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   76 |             left = new node2(l, l + r >> 1);
      |                                 ~~^~~
game.cpp:77:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   77 |             right = new node2((l + r >> 1) + 1, r);
      |                                ~~^~~