Advertisement
Galebickosikasa

Untitled

Jan 5th, 2021
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
  2. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
  3. // #pragma comment(linker, "/stack:200000000"]
  4.  
  5. #include <iostream>
  6. #include <vector>
  7. #include <cmath>
  8. #include <algorithm>
  9. #include <unordered_set>
  10. #include <unordered_map>
  11. #include <set>
  12. #include <map>
  13. #include <queue>
  14. #include <deque>
  15. #include <bitset>
  16. #include <stack>
  17. #include <random>
  18. #include <fstream>
  19. #include <sstream>
  20. #include <chrono>
  21.  
  22. #define fi first
  23. #define se second
  24. #define pb push_back
  25. #define ll long long
  26. #define ld long double
  27. #define hm unordered_map
  28. #define pii pair<int, int>
  29. #define sz(a) (int)a.size()
  30. #define all(a) a.begin(), a.end()
  31. #define cinv(v) for (auto& x: v) cin >> x
  32. #define fr(i, n) for (int i = 0; i < n; ++i)
  33. #define fl(i, l, n) for (int i = l; i < n; ++i)
  34.  
  35. #define int ll
  36.  
  37. template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
  38. template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}
  39.  
  40. using namespace std;
  41.  
  42. #ifdef LOCAL
  43. #define dbg(x) cerr << #x << " : " << x << '\n'
  44. const int maxn = 20;
  45. #else
  46. #define dbg(x)
  47. const int maxn = 500 + 20;
  48. #endif
  49.  
  50. //tg: @galebickosikasa
  51.  
  52. ostream& operator << (ostream& out, const pii& v) {
  53. out << v.fi << ", " << v.se;
  54. return out;
  55. }
  56.  
  57. template<typename T> ostream& operator << (ostream& out, const vector<T>& v) {
  58. for (auto& x: v) out << x << " ";
  59. return out;
  60. }
  61.  
  62. istream& operator >> (istream& in, pii& a) {
  63. in >> a.fi >> a.se;
  64. return in;
  65. }
  66.  
  67. const ll inf = (ll) 2e9;
  68. const ld pi = asin (1) * 2;
  69. const ld eps = 1e-8;
  70. const ll mod = (ll)1e9 + 7;
  71. const ll ns = 97;
  72.  
  73. mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  74.  
  75. struct tree {
  76. vector<int> a, b, c; // unused_high, unused_low, res
  77. int size = 0, capacity;
  78.  
  79. tree (int n) {
  80. while ((1<<size) < n) ++size;
  81. ++size;
  82. size = (1<<size);
  83. capacity = (size>>1);
  84. a = b = c = vector<int> (size);
  85. }
  86.  
  87. inline void render (int i) {
  88. i >>= 1;
  89. while (i) {
  90. int t = min (a[i * 2 + 1], b[i * 2]);
  91. a[i] = a[i * 2] + a[i * 2 + 1] - t;
  92. b[i] = b[i * 2] + b[i * 2 + 1] - t;
  93. res[i] = res[i * 2] + res[i * 2 + 1] + t;
  94. i >>= 1;
  95. }
  96. }
  97.  
  98. inline void add (int x, int y) {
  99. x += capacity, y += capacity;
  100. ++b[y];
  101. ++a[x];
  102. render (x);
  103. render (y);
  104. }
  105.  
  106.  
  107.  
  108.  
  109. signed main () {
  110. ios_base::sync_with_stdio(false);
  111. cin.tie(nullptr);
  112. cout.tie(nullptr);
  113. #ifndef LOCAL
  114. freopen ("cardgame.in", "r", stdin);
  115. freopen ("cardgame.out", "w", stdout);
  116. #endif
  117.  
  118. int n;
  119. cin >> n;
  120. vector<int> used (2 * n);
  121. vector<int> a (n);
  122. cinv (a);
  123. for (auto& x: a) --x;
  124. for (auto& x: a) used[x] = 1;
  125. vector<int> b;
  126. fr (i, n) if (!used[i]) b.pb (i);
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. }
  134.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement