fork download
  1. #include <bits/stdc++.h>
  2. #include <stdio.h>
  3.  
  4. #define __Shibae__ signed main()
  5. #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  6. #define fiopen(Path) freopen(Path".INP", "r", stdin); freopen(Path".OUT", "w", stdout);
  7. #define fipen(Path) freopen(Path".INP", "r", stdin);
  8. #define sz(s) (int)s.size()
  9. #define all(x) x.begin(), x.end()
  10. #define maxHeap priority_queue<int>
  11. #define minHeap priority_queue<int, vector<int>, greater<int>>
  12. #define getBit(x, k) (((x) >> (k)) & 1)
  13. #define MASK(i) (1LL << (i))
  14. #define SQR(x) (1LL * ((x) * (x)))
  15. #define db double
  16. #define ld long double
  17. #define ui unsigned int
  18. #define ll long long
  19. #define ii pair<int, int>
  20. #define pli pair<ll, int>
  21. #define pil pair<int, ll>
  22. #define pll pair<ll, ll>
  23. #define fi first
  24. #define se second
  25.  
  26. #define FOR(i, a, b) for(int i = a, _b = b; i <= _b; i += 1)
  27. #define FOD(i, a, b) for(int i = a, _b = b; i >= _b; i -= 1)
  28. #define REP(i, a) for(int i = 0, _a = a; i < _a; i++)
  29. #define pb push_back
  30. #define fau(u, a) for(auto &u : a)
  31. #define debug return cout << "debug", void();
  32.  
  33. using namespace std;
  34.  
  35. const ll mod = 1e9 + 7;
  36. const int INF = 1e9 + 7;
  37. const ll INFLL = (ll)2e18 + 7LL;
  38. const ld PI = acos(-1);
  39. const int MAX = 5e5+5;
  40.  
  41. const int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
  42. const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
  43.  
  44. mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
  45.  
  46. ll Rand(ll l, ll r)
  47. {
  48. return uniform_int_distribution<ll>(l, r)(rd);
  49. }
  50.  
  51. template<class SHIBA, class ENGINE>
  52. bool minimize(SHIBA &x, const ENGINE y)
  53. {
  54. if(x > y)
  55. {
  56. x = y;
  57. return true;
  58. }
  59. else return false;
  60. }
  61. template<class SHIBA, class ENGINE>
  62. bool maximize(SHIBA &x, const ENGINE y)
  63. {
  64. if(x < y)
  65. {
  66. x = y;
  67. return true;
  68. }
  69. else return false;
  70. }
  71.  
  72.  
  73. /* Template by: Nguyen Nhat Anh from Luong Van Chanh High School for the gifted */
  74. /* From Min Tuoi with love */
  75. /** TRY HARD **/
  76. /** ORZ **/
  77.  
  78. /* -----------------[ MAIN CODE ]----------------- */
  79.  
  80. int n;
  81. int a[MAX];
  82. vector<int> arr;
  83.  
  84. struct FenwickTree
  85. {
  86. int bit[MAX];
  87.  
  88. void update(int i, int k)
  89. {
  90. for (i; i <= n; i += i & -i) bit[i] += k;
  91. }
  92.  
  93. int get(int i)
  94. {
  95. int res = 0;
  96. for (; i; i -= i & -i) res += bit[i];
  97. return res;
  98. }
  99. }pre, suf;
  100.  
  101. void input()
  102. {
  103. cin >> n;
  104. FOR(i, 1, n)
  105. {
  106. cin >> a[i];
  107. arr.pb(a[i]);
  108. }
  109. }
  110.  
  111. void solve()
  112. {
  113. sort(all(arr));
  114. arr.resize(unique(all(arr)) - arr.begin());
  115. FOR(i, 1, n) a[i] = lower_bound(all(arr), a[i]) - arr.begin() + 1;
  116. pre.update(a[1], 1);
  117. FOR(i, 2, n) suf.update(a[i], 1);
  118.  
  119. ll res = 0;
  120.  
  121. FOR(i, 2, n-1)
  122. {
  123. suf.update(a[i], -1);
  124. res += 1LL * pre.get(a[i]-1) * suf.get(a[i] - 1);
  125. pre.update(a[i], 1);
  126. }
  127. cout << res;
  128. }
  129.  
  130. __Shibae__
  131. {
  132. FOR(_, 1, 100)
  133. {
  134. ofstream out("dooki.inp");
  135.  
  136. int n = Rand(1, 100);
  137.  
  138. out << n << "\n";
  139. FOR(i, 1, n) out << Rand(1, 1e9) << " ";
  140.  
  141. map<ii, int> map;
  142.  
  143. /* Sinh Cay
  144.   FOR(i, 2, n)
  145. // {
  146. // int u = Rand(1, i-1);
  147. // out << u << " " << i << "\n";
  148. // mp[{u, i}] = mp[{i, u}] = 1;
  149. // }
  150. // THem cai nay thi la sinh do thi lien thong n dinh
  151. // FOR(i, 1, m-n+1)
  152. // {
  153. // int u = Rand(1, n-1);
  154. // int v = Rand(u+1, n);
  155. // while(mp[{u, v}] == 1)
  156. // {
  157. // u = Rand(1, n-1);
  158. // v = Rand(u+1, n);
  159. // }
  160. //
  161. // out << u << " " << v << "\n";
  162. // mp[{u, v}] = mp[{v, u}] = 1;
  163. // }
  164. */
  165.  
  166. // FOR(i, 1, m-n+1) // sinh do thi backy
  167. // {
  168. // int u = Rand(1, n-1);
  169. // int v = Rand(u+1, n);
  170. // while(mp[{u, v}] == 1)
  171. // {
  172. // u = Rand(1, n-1);
  173. // v = Rand(u+1, n);
  174. // }
  175. //
  176. // out << u << " " << v << "\n";
  177. // mp[{u, v}] = mp[{v, u}] = 1;
  178. // }
  179.  
  180.  
  181. out.close();
  182.  
  183. system("f.exe");
  184. system("trau.exe");
  185.  
  186. if (system("fc trau.out dooki.out"))
  187. {
  188. return 0;
  189. }
  190.  
  191. }
  192.  
  193.  
  194. return 0;
  195. }
  196.  
Success #stdin #stdout #stderr 0.01s 5640KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
sh: 1: f.exe: not found
sh: 1: trau.exe: not found
sh: 1: fc: not found