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. vector<string> Explode_L(const string &str, const string &d){
  7. int s = 0;
  8. int i = 0;
  9. int j;
  10. vector<string> res;
  11. while(i + d.size() - 1 < str.size()){
  12. for(j=(0);j<(d.size());j++){
  13. if(str[i+j] != d[j]){
  14. break;
  15. }
  16. }
  17. if(j != d.size()){
  18. i++;
  19. continue;
  20. }
  21. res.push_back(str.substr(s, i-s));
  22. s = (i += d.size());
  23. }
  24. res.push_back(str.substr(s));
  25. return res;
  26. }
  27. #define main dummy_main
  28. int main(){
  29. return 0;
  30. }
  31. #undef main
  32. class Solution{
  33. public:
  34. int countValidWords(string sentence){
  35. int res = 0;
  36. vector<string> tmp =Explode_L(sentence, " ");
  37. for(string str : tmp){
  38. if(str.size()){
  39. int i;
  40. int a = 0;
  41. for(i=(0);i<(str.size());i++){
  42. if(isdigit(str[i])){
  43. goto Lj4PdHRW;
  44. }
  45. if(str[i] == '-'){
  46. if(i-1 < 0 || !isalpha(str[i-1])){
  47. goto Lj4PdHRW;
  48. }
  49. if(!isalpha(str[i+1])){
  50. goto Lj4PdHRW;
  51. }
  52. a++;
  53. continue;
  54. }
  55. if(!isalpha(str[i]) && i != str.size()-1){
  56. goto Lj4PdHRW;
  57. }
  58. }
  59. if(a <= 1){
  60. res++;
  61. }
  62. }
  63. Lj4PdHRW:;
  64. }
  65. return res;
  66. }
  67. }
  68. ;
  69. // cLay version 20211024-1
  70.  
  71. // --- original code ---
  72. // #define main dummy_main
  73. // {}
  74. // #undef main
  75. //
  76. // class Solution {
  77. // public:
  78. // int countValidWords(string sentence) {
  79. // int res = 0;
  80. // VS tmp = Explode(sentence, " ");
  81. // for(string str : tmp) if(str.size()) {
  82. // int a = 0;
  83. // rep(i,str.size()){
  84. // if(isdigit(str[i])) break_continue;
  85. // if(str[i] == '-'){
  86. // if(i-1 < 0 || !isalpha(str[i-1])) break_continue;
  87. // if(!isalpha(str[i+1])) break_continue;
  88. // a++, continue;
  89. // }
  90. // if(!isalpha(str[i]) && i != str.size()-1) break_continue;
  91. // }
  92. // if(a <= 1) res++;
  93. // }
  94. // return res;
  95. // }
  96. // };
  97.  
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