제출 #411073

#제출 시각아이디문제언어결과실행 시간메모리
411073zipdang04원숭이와 사과 나무 (IZhO12_apple)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; */ typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef map<int, int> mii; typedef unordered_map<int, int> umii; typedef map<ll, ll> mll; typedef unordered_map<ll, ll> umll; /* struct Node { int node, len; Node() {node = len = 0;} Node(int node, int len) {this -> node = node, this -> len = len;} }; typedef vector<Node> vg; */ #define MOD 1000000007 #define fi first #define se second #define pf push_front #define pb push_back #define FOR(type, i, a, b) for(type i = (a); i <= (b); i++) #define FORD(type, i, b, a) for(type i = (b); i >= (a); i--) #define testBit(n, bit) ((n >> bit) & 1) #define flipBit(n, bit) (n ^ (1ll << bit)) #define cntBit(n) __builtin_popcount(n) #define cntBitll(n) __builtin_popcountll(n) #define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); const int MAX = 1000000000; class Node{ private: int lo, hi, cnt; bool stop; Node *left, *right; public: Node(int lo, int hi): lo(lo), hi(hi){ cnt = 0; stop = true; left = nullptr, right = nullptr; } void update(int posL, int posR){ if (posR < lo || hi < posL) return; if (posL <= lo && hi <= posR){ cnt = hi - lo + 1; stop = true; delete left; left = nullptr; delete right; right = nullptr; return; } if (stop){ if (cnt) return; stop = false; int mid = (lo + hi) >> 1; left = new Node(lo, mid); right = new Node(mid + 1, hi); } left -> update(posL, posR); right -> update(posL, posR); cnt = left -> cnt + right -> cnt; } int get(int posL, int posR){ if (posR < lo || hi < posL) return 0; if (posL <= lo && hi <= posR) return cnt; if (stop){ if (!cnt) return 0; assert(cnt == hi - lo + 1); if (posR <= hi) return posR - lo + 1; else return hi - posL + 1; } return left -> get(posL, posR) + right -> get(posL, posR); } }; Node *root = new Node(1, MAX); int m, c; main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> m; c = 0; FOR(int, _, 1, m){ int d, x, y; cin >> d >> x >> y; if (d == 1){ c = root -> get(x + c, y + c); cout << c << '\n'; } else root -> update(x + c, y + c); } }

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

apple.cpp:103:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  103 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...