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. int sz;
  10. int cur;
  11. int n;
  12. string alpha;
  13. int len;
  14. string now;
  15. string res[10100];
  16. void doit(int dep, int st){
  17. int i;
  18. if(sz >= 10010){
  19. return;
  20. }
  21. if(dep==len){
  22. res[sz++] = now;
  23. return;
  24. }
  25. for(i=(st);i<(n);i++){
  26. now[dep] = alpha[i];
  27. doit(dep+1, i+1);
  28. }
  29. }
  30. class CombinationIterator{
  31. public:
  32. CombinationIterator(string characters, int combinationLength){
  33. int i;
  34. sz = cur = 0;
  35. alpha = characters;
  36. len = combinationLength;
  37. n = alpha.size();
  38. now = "";
  39. for(i=(0);i<(len);i++){
  40. now += 'a';
  41. }
  42. doit(0, 0);
  43. }
  44. string next(){
  45. return res[cur++];
  46. }
  47. bool hasNext(){
  48. return cur < sz;
  49. }
  50. }
  51. ;
  52. // cLay varsion 20191214-1
  53.  
  54. // --- original code ---
  55. // #define main dummy_main
  56. // {}
  57. // #undef main
  58. //
  59. // int sz, cur, n;
  60. // string alpha; int len;
  61. // string now;
  62. // string res[10100];
  63. //
  64. // void doit(int dep, int st){
  65. // if(sz >= 10010) return;
  66. // if(dep==len) res[sz++] = now, return;
  67. // rep(i,st,n){
  68. // now[dep] = alpha[i];
  69. // doit(dep+1, i+1);
  70. // }
  71. // }
  72. //
  73. // class CombinationIterator {
  74. // public:
  75. // CombinationIterator(string characters, int combinationLength) {
  76. // sz = cur = 0;
  77. // alpha = characters;
  78. // len = combinationLength;
  79. // n = alpha.size();
  80. // now = "";
  81. // rep(i,len) now += 'a';
  82. // doit(0, 0);
  83. // }
  84. // string next() {
  85. // return res[cur++];
  86. // }
  87. // bool hasNext() {
  88. // return cur < sz;
  89. // }
  90. // };
  91.  
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