fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. void*wmem;
  5. char memarr[96000000];
  6. template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  7. static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  8. (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  9. (*arr)=(T*)(*mem);
  10. (*mem)=((*arr)+x);
  11. }
  12. template<class T> inline void walloc1d(T **arr, int x1, int x2, void **mem = &wmem){
  13. walloc1d(arr, x2-x1, mem);
  14. (*arr) -= x1;
  15. }
  16. template<class T> struct static_segtree_Add_At{
  17. int N;
  18. int mem;
  19. int has_new;
  20. T*dat;
  21. T*ad;
  22. void malloc(int maxN, int once = 0){
  23. dat = new T[maxN];
  24. ad = new T[maxN];
  25. if(once){
  26. setN(maxN);
  27. }
  28. }
  29. void walloc(int maxN, int once = 0, void **mem = &wmem){
  30. walloc1d(&dat, maxN, mem);
  31. walloc1d(&ad, maxN, mem);
  32. if(once){
  33. setN(maxN);
  34. }
  35. }
  36. void free(void){
  37. delete [] dat;
  38. delete [] ad;
  39. }
  40. T& operator[](int i){
  41. return dat[i];
  42. }
  43. void setN(int n, int zerofill = 1, int dobuild = 1){
  44. N = n;
  45. if(zerofill){
  46. int i;
  47. for(i=(0);i<(N);i++){
  48. dat[i] = 0;
  49. }
  50. }
  51. if(dobuild){
  52. build();
  53. }
  54. }
  55. void build(void){
  56. int i;
  57. for(i=(0);i<(N);i++){
  58. ad[i] = 0;
  59. }
  60. has_new = 0;
  61. }
  62. inline void apply(void){
  63. if(has_new){
  64. int i;
  65. T s;
  66. s = 0;
  67. for(i=(0);i<(N);i++){
  68. dat[i] += (s += ad[i]);
  69. ad[i] = 0;
  70. }
  71. }
  72. has_new = 0;
  73. }
  74. inline void add(int a, int b, T val){
  75. has_new = 1;
  76. ad[a] += val;
  77. if(b < N){
  78. ad[b] -= val;
  79. }
  80. }
  81. inline T getAt(int i){
  82. apply();
  83. return dat[i];
  84. }
  85. }
  86. ;
  87. #define main dummy_main
  88. int main(){
  89. wmem = memarr;
  90. return 0;
  91. }
  92. #undef main
  93. class Solution{
  94. public:
  95. int minMoves(vector<int>& A, int limit){
  96. int i;
  97. dummy_main();
  98. int x;
  99. int y;
  100. int N = A.size();
  101. int res = 1073709056;
  102. static_segtree_Add_At<int> t;
  103. t.walloc(2*limit, 1);
  104. for(i=(0);i<(N/2);i++){
  105. {
  106. auto Q5VJL1cS = (A[i]-1);
  107. auto e98WHCEY = ( A[N-1-i]-1);
  108. x = Q5VJL1cS;
  109. y = e98WHCEY;
  110. }
  111. if(x > y){
  112. swap(x, y);
  113. }
  114. ;
  115. t.add(0, x, 2);
  116. t.add(x, x+y, 1);
  117. t.add(x+y+1, y+limit, 1);
  118. t.add(y+limit, 2*limit, 2);
  119. }
  120. {
  121. int cTE1_r3A;
  122. remove_reference<decltype(t.getAt(cTE1_r3A))>::type RZTsC2BF;
  123. int FmcKpFmN = 0;
  124. if((0) > ((2*limit)-1)){
  125. RZTsC2BF = numeric_limits<remove_reference<decltype(t.getAt(cTE1_r3A))>::type>::max();
  126. }
  127. else{
  128. for(cTE1_r3A = 0; cTE1_r3A <= (2*limit)-1; cTE1_r3A++){
  129. if(FmcKpFmN == 0){
  130. RZTsC2BF = t.getAt(cTE1_r3A);
  131. FmcKpFmN = 1;
  132. continue;
  133. }
  134. const auto WYIGIcGE = t.getAt(cTE1_r3A);
  135. if(RZTsC2BF > WYIGIcGE){
  136. RZTsC2BF = WYIGIcGE;
  137. }
  138. }
  139. }
  140. return RZTsC2BF;
  141. }
  142. }
  143. }
  144. ;
  145. // cLay version 20201206-1
  146.  
  147. // --- original code ---
  148. // #define main dummy_main
  149. // {}
  150. // #undef main
  151. //
  152. // class Solution {
  153. // public:
  154. // int minMoves(vector<int>& A, int limit) {
  155. // dummy_main();
  156. // int x, y, N = A.size();
  157. // int res = int_inf;
  158. // static_segtree_Add_At<int> t;
  159. // t.walloc(2*limit, 1);
  160. // rep(i,N/2){
  161. // (x, y) = (A[i]-1, A[N-1-i]-1);
  162. // sortE(x, y);
  163. // t.add(0, x, 2);
  164. // t.add(x, x+y, 1);
  165. // t.add(x+y+1, y+limit, 1);
  166. // t.add(y+limit, 2*limit, 2);
  167. // }
  168. // return min[i,0,2*limit](t.getAt(i));
  169. // }
  170. // };
  171.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty