fork download
  1. #pragma GCC optimize("Ofast")
  2. #pragma GCC optimize("unroll-loops")
  3. #pragma GCC optimize("inline")
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. template<class T> struct cLtraits_identity{
  7. using type = T;
  8. }
  9. ;
  10. template<class T> using cLtraits_try_make_signed =
  11. typename conditional<
  12. is_integral<T>::value,
  13. make_signed<T>,
  14. cLtraits_identity<T>
  15. >::type;
  16. template <class S, class T> struct cLtraits_common_type{
  17. using tS = typename cLtraits_try_make_signed<S>::type;
  18. using tT = typename cLtraits_try_make_signed<T>::type;
  19. using type = typename common_type<tS,tT>::type;
  20. }
  21. ;
  22. template<class S, class T> inline auto min_L(S a, T b)
  23. -> typename cLtraits_common_type<S,T>::type{
  24. return (typename cLtraits_common_type<S,T>::type) a <= (typename cLtraits_common_type<S,T>::type) b ? a : b;
  25. }
  26. #define main dummy_main
  27. int main(){
  28. return 0;
  29. }
  30. #undef main
  31. int dp1[100000+2];
  32. int dp2[100000+2];
  33. class Solution{
  34. public:
  35. int minFlips(string s){
  36. int i;
  37. int res = 1073709056;
  38. int N = s.size();
  39. dp1[0] = dp2[0] = 0;
  40. for(i=(0);i<(N);i++){
  41. if(s[i]-'0'==i%2){
  42. dp1[i+1] = dp1[i] +1;
  43. }
  44. else{
  45. dp1[i+1] = dp1[i] +0;
  46. }
  47. }
  48. for(i=(0);i<(N);i++){
  49. if(s[N-1-i]-'0'==(i+1)%2){
  50. dp2[i+1] = dp2[i] +1;
  51. }
  52. else{
  53. dp2[i+1] = dp2[i] +0;
  54. }
  55. }
  56. int cTE1_r3A;
  57. remove_reference<decltype(dp1[cTE1_r3A]+dp2[N-cTE1_r3A])>::type RZTsC2BF;
  58. int FmcKpFmN = 0;
  59. if((0) > ((N+1)-1)){
  60. RZTsC2BF = numeric_limits<remove_reference<decltype(dp1[cTE1_r3A]+dp2[N-cTE1_r3A])>::type>::max();
  61. }
  62. else{
  63. for(cTE1_r3A = 0; cTE1_r3A <= (N+1)-1; cTE1_r3A++){
  64. if(FmcKpFmN == 0){
  65. RZTsC2BF =min_L(dp1[cTE1_r3A]+dp2[N-cTE1_r3A], N-(dp1[cTE1_r3A]+dp2[N-cTE1_r3A]));
  66. FmcKpFmN = 1;
  67. continue;
  68. }
  69. const auto WYIGIcGE =min_L(dp1[cTE1_r3A]+dp2[N-cTE1_r3A], N-(dp1[cTE1_r3A]+dp2[N-cTE1_r3A]));
  70. if(RZTsC2BF > WYIGIcGE){
  71. RZTsC2BF = WYIGIcGE;
  72. }
  73. }
  74. }
  75. return RZTsC2BF;
  76. }
  77. }
  78. ;
  79. // cLay version 20210607-1
  80.  
  81. // --- original code ---
  82. // #define main dummy_main
  83. // {}
  84. // #undef main
  85. //
  86. // int dp1[1d5+2], dp2[];
  87. //
  88. // class Solution {
  89. // public:
  90. // int minFlips(string s) {
  91. // int res = int_inf, N = s.size();
  92. // dp1[0] = dp2[0] = 0;
  93. // rep(i,N) dp1[i+1] = dp1[i] + if[s[i]-'0'==i%2, 1, 0];
  94. // rep(i,N) dp2[i+1] = dp2[i] + if[s[N-1-i]-'0'==(i+1)%2, 1, 0];
  95. // return min[i,0,N+1](min(dp1[i]+dp2[N-i], N-(dp1[i]+dp2[N-i])));
  96. // }
  97. // };
  98.  
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