Advertisement
TrickmanOff

Untitled

Aug 10th, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iostream>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <functional>
  7. #include <bitset>
  8. #include <string>
  9. #include <stack>
  10. #include <time.h>
  11. #include <random>
  12. #include <unordered_set>
  13. using namespace std;
  14.  
  15. #define ll long long
  16. #define cin in
  17. #define cout out
  18. #define pii pair<int, int>
  19. #define ld long double
  20. #define u_set unordered_set
  21. #define uid uniform_int_distribution
  22.  
  23. ifstream in("input.txt");
  24. ofstream out("output.txt");
  25.  
  26. int H, W, n, cur_h = 1;
  27. const int TREE_SZ = 524288, INF = 2e9;
  28. int tree[TREE_SZ];
  29.  
  30. struct line{
  31.     int len, h;
  32.     line() : len(W), h(cur_h++) {}
  33. };
  34.  
  35. //size of 'lines' = cur_h
  36. vector<line> lines;
  37.  
  38. void build(int v, int lb, int rb) {
  39.     if(lb == rb) {
  40.         tree[v] = lines[lb].h;
  41.         return;
  42.     }
  43.    
  44.     int mid = (lb + rb)/2;
  45.     build(2*v, lb, mid);
  46.     build(2*v+1, mid+1, rb);
  47. }
  48.  
  49. void rebuild() {
  50.     build(1, 0, cur_h-1);
  51. }
  52.  
  53. void del(int v, int lb, int rb, int pos) {
  54.     if(lb == rb && rb == pos) {
  55.         tree[v] = INF;
  56.         return;
  57.     }
  58.    
  59.     int mid = (lb + rb)/2;
  60.     if(pos <= mid)
  61.         del(2*v, lb, mid, pos);
  62.     else
  63.         del(2*v+1, mid+1, rb, pos);
  64.    
  65.     tree[v] = min(tree[2*v], tree[2*v+1]);
  66. }
  67.  
  68. void del(int pos) {
  69.     del(1, 0, cur_h-1, pos);
  70. }
  71.  
  72. int get_min(int v, int l, int r, int lb, int rb) {
  73.     if(lb == l && rb == r)
  74.         return tree[v];
  75.    
  76.     int mid = (lb + rb)/2;
  77.     return min(get_min(2*v, l, min(mid, r), lb, mid),
  78.                get_min(2*v+1, max(mid+1, l), r, mid+1, rb));
  79. }
  80.  
  81. int get_min(int l, int r) {
  82.     return get_min(1, 0, cur_h-1, l, r);
  83. }
  84.  
  85. //finds first num that has more or equal 'len' than 'a' and returns its position in the array
  86. int bin_search(int a) {
  87.     if(lines.back().len < a)
  88.         return -1;
  89.    
  90.     int l = -1, r = cur_h - 1;
  91.    
  92.     while(r - l > 1) {
  93.         int mid = (l+r)/2;
  94.         if(lines[mid].len >= a)
  95.             r = mid;
  96.         else
  97.             l = mid;
  98.     }
  99.    
  100.     return r;
  101. }
  102.  
  103. void resort() {
  104.    
  105. }
  106.  
  107. class Compare{
  108. public:
  109.     bool operator()(const line &a, const line &b) const {
  110.         return a.len < b.len;
  111.     }
  112. };
  113.  
  114. vector<int> queries;
  115.  
  116. void input() {
  117.     cin >> H >> W >> n;
  118.     queries.resize(n);
  119.     for(int &x : queries)
  120.         cin >> x;
  121. }
  122.  
  123.  
  124.  
  125. int main()
  126. {
  127.     input();
  128.     int i = 0;
  129.     for(; (1 << i) < 400000; i++) ;
  130.     cout << (1 << i);
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement