제출 #798751

#제출 시각아이디문제언어결과실행 시간메모리
798751vjudge1게임 (IOI13_game)C++17
컴파일 에러
0 ms0 KiB
#include "game.h" #include<bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> #define el '\n' #define fi first #define sc second #define int ll #define pii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; //#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> //using namespace __gnu_pbds; using ll=long long; using ull=unsigned long long; using ld=long double; const int mod=1e9+7; const int N=1e5+11; // find_by_order, order_of_key int m, n, q, x, y, u, v, val, tt; int gcd(int x, int y) { if(y==0) return x; return gcd(y, x%y); } 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) { int mid=(l+r)>>1; left = new node1(l, mid); right = new node1(mid+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 a, int b) { if (r < a || b < l) return 0; down(); if (a <= l && r <= b) return ss; return gcd(left->get(a, b), right->get(a, b)); } }; 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(1, n); } void down() { if (l!=r && left == NULL) { int mid=(l+r)>>1; left = new node2(l, mid); right = new node2(mid+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)); } }; 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; } void init(int R, int C) { node2* root = new node2(1, m); } void update(int P, int Q, long long K) { root->update(x, y, val); } long long calculate(int P, int Q, int U, int V) { return root->get(x, y, u, v); } /* void sol() { cin >> m >> n >> q; node2* root = new node2(1, m); while(q--) { cin >> tt; if(tt==1) { cin >> x >> y >> val; x++; y++; root->update(x, y, val); } else { cin >> x >> y >> u >> v; x++; y++; u++; v++; cout << root->get(x, y, u, v) << el; } } } signed main() { // freopen("divisor.INP", "r", stdin); // freopen("divisor.OUT", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); int t=1; //cin >> t; while(t--) { sol(); } } */

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

game.cpp: In function 'void init(ll, ll)':
game.cpp:127:12: warning: unused variable 'root' [-Wunused-variable]
  127 |     node2* root = new node2(1, m);
      |            ^~~~
game.cpp: In function 'void update(ll, ll, long long int)':
game.cpp:131:6: error: 'root' was not declared in this scope
  131 |      root->update(x, y, val);
      |      ^~~~
game.cpp: In function 'long long int calculate(ll, ll, ll, ll)':
game.cpp:135:12: error: 'root' was not declared in this scope
  135 |     return root->get(x, y, u, v);
      |            ^~~~