이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#include <iostream> //cin, cout
#include "game.h"
/*
#include <fstream>
std::ifstream cin ("ex.in");
std::ofstream cout ("ex.out");
*/
// includes
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <unordered_set>
#include <stack>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>
#include <chrono>
//usings
using namespace std;
using namespace __gnu_pbds;
// misc
#define ll long long
#define pb push_back
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
template<typename T, typename U> bool emin(T &a, const U &b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool emax(T &a, const U &b){ return b > a ? a = b, true : false; }
typedef uint64_t hash_t;
// vectors
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vvpii vector<vector<pair<int, int>>>
#define vppipi vector<pair<int, pair<int, int>>>
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>
#define vpll vector<pair<ll, ll>>
#define vb vector<bool>
#define vvb vector<vb>
#define vs vector<string>
#define sz(x) (int)x.size()
#define rz resize
#define all(x) x.begin(), x.end()
// pairs
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define f first
#define s second
// sets
#define si set<int>
#define sl set<ll>
#define ss set<string>
#define in insert
template <class T> using iset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// maps
#define mii map<int, int>
#define mll map<ll, ll>
// loops
#define FR(x, z, y) for (int x = z; x < y; x++)
#define FRe(x, z, y) FR(x, z, y + 1)
#define F(x, y) FR(x, 0, y)
#define Fe(x, y) F(x, y + 1)
#define A(x, y) for(auto &x : y)
int Y, X;
struct Xnode{
Xnode(int x, int y) : l(x), r(y), v(0), lc(NULL), rc(NULL) {}
ll v;
int l, r;
Xnode *lc, *rc;
};
struct Ynode{
Ynode() : lc(NULL), rc(NULL), node(NULL) {}
Xnode *node;
Ynode *lc, *rc;
} *root;
ll gcd2(ll x, ll y){
if(y == 0) return x;
return gcd2(y, x % y);
}
void upd2(Xnode *cur, int x, ll v){
int l = cur->l, r = cur->r, m = (r + l) / 2;
if(l == r){
cur->v = v;
return;
}
if(x <= m){
if(!cur->lc) cur->lc = new Xnode(l, m);
upd2(cur->lc, x, v);
} else {
if(!cur->rc) cur->rc = new Xnode(m + 1, r);
upd2(cur->rc, x, v);
}
}
void upd1(Ynode *cur, int l, int r, int y, int x, ll v){
if(l == r) {upd2(cur->node, x, v); return;}
int m = (r + l) / 2;
if(y <= m){
if(!cur->lc) cur->lc = new Ynode;
upd1(cur->lc, l, m, y, x, v);
} else {
if(!cur->rc) cur->rc = new Ynode;
upd1(cur->rc, m + 1, r, y, x, v);
}
}
ll get2(Xnode *cur, int rl, int rr){
if(cur == NULL || cur->r < rl || cur->l > rr) return 0;
if(rl <= cur->l && cur->r <= rr) return cur->v;
return gcd2(get2(cur->lc, rl, rr), get2(cur->rc, rl, rr));
}
ll get1(Ynode *cur, int l, int r, int rl, int rr, int xl, int xr){
if(cur == NULL || l > rr || r < rl) return 0;
if(rl <= l && r <= rr) return get2(cur->node, xl, xr);
int m = (r + l) / 2;
return gcd(get1(cur->lc, l, m, rl, rr, xl, xr), get1(cur->rc, m + 1, r, rl, rr, xl, xr));
}
void init(int R, int C){
Y = R, X = C;
root = new Ynode;
}
void update(int P, int Q, ll K){
P++; Q++;
upd1(root, 1, Y, P, Q, K);
}
ll calculate(int P, int Q, int U, int V){
P++; Q++; U++; V++;
return get1(root, 1, Y, P, U, Q, V);
}
컴파일 시 표준 에러 (stderr) 메시지
game.cpp: In constructor 'Xnode::Xnode(int, int)':
game.cpp:94:9: warning: 'Xnode::r' will be initialized after [-Wreorder]
94 | int l, r;
| ^
game.cpp:93:5: warning: 'long long int Xnode::v' [-Wreorder]
93 | ll v;
| ^
game.cpp:92:2: warning: when initialized here [-Wreorder]
92 | Xnode(int x, int y) : l(x), r(y), v(0), lc(NULL), rc(NULL) {}
| ^~~~~
game.cpp: In constructor 'Ynode::Ynode()':
game.cpp:101:14: warning: 'Ynode::rc' will be initialized after [-Wreorder]
101 | Ynode *lc, *rc;
| ^~
game.cpp:100:9: warning: 'Xnode* Ynode::node' [-Wreorder]
100 | Xnode *node;
| ^~~~
game.cpp:99:2: warning: when initialized here [-Wreorder]
99 | Ynode() : lc(NULL), rc(NULL), node(NULL) {}
| ^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |