fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define main dummy_main
  5. int main(){
  6. return 0;
  7. }
  8. #undef main
  9. class Solution{
  10. public:
  11. int numberOfSubstrings(string s){
  12. long long res = 0;
  13. int i;
  14. int j;
  15. int N = s.size();
  16. int a = 0;
  17. int b = 0;
  18. int c = 0;
  19. j = 0;
  20. for(i=(0);i<(N);i++){
  21. while(j < N && (a==0 || b==0 || c==0)){
  22. if(s[j]=='a'){
  23. a++;
  24. }
  25. if(s[j]=='b'){
  26. b++;
  27. }
  28. if(s[j]=='c'){
  29. c++;
  30. }
  31. j++;
  32. }
  33. if(a==0 || b==0 || c==0){
  34. break;
  35. }
  36. res += N - j + 1;
  37. if(s[i]=='a'){
  38. a--;
  39. }
  40. if(s[i]=='b'){
  41. b--;
  42. }
  43. if(s[i]=='c'){
  44. c--;
  45. }
  46. }
  47. return res;
  48. }
  49. }
  50. ;
  51. // cLay varsion 20200217-1
  52.  
  53. // --- original code ---
  54. // #define main dummy_main
  55. // {}
  56. // #undef main
  57. //
  58. // class Solution {
  59. // public:
  60. // int numberOfSubstrings(string s) {
  61. // ll res = 0;
  62. // int i, j, N = s.size();
  63. // int a = 0, b = 0, c = 0;
  64. //
  65. // j = 0;
  66. // rep(i,N){
  67. // while(j < N && (a==0 || b==0 || c==0)){
  68. // if(s[j]=='a') a++;
  69. // if(s[j]=='b') b++;
  70. // if(s[j]=='c') c++;
  71. // j++;
  72. // }
  73. // if(a==0 || b==0 || c==0) break;
  74. // res += N - j + 1;
  75. // if(s[i]=='a') a--;
  76. // if(s[i]=='b') b--;
  77. // if(s[i]=='c') c--;
  78. // }
  79. //
  80. // return res;
  81. // }
  82. // };
  83.  
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