fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. vector<string> Explode_L(const string &str, const string &d){
  5. int s = 0;
  6. int i = 0;
  7. int j;
  8. vector<string> res;
  9. while(i + d.size() - 1 < str.size()){
  10. for(j=0;j<(d.size());j++){
  11. if(str[i+j] != d[j]){
  12. break;
  13. }
  14. }
  15. if(j != d.size()){
  16. i++;
  17. continue;
  18. }
  19. res.push_back(str.substr(s, i-s));
  20. s = (i += d.size());
  21. }
  22. res.push_back(str.substr(s));
  23. return res;
  24. }
  25. string Implode_L(const vector<string> &v, const string &d){
  26. int i;
  27. string res;
  28. if(v.size()==0){
  29. return res;
  30. }
  31. res += v[0];
  32. for(i=(1);i<(v.size());i++){
  33. res += d;
  34. res += v[i];
  35. }
  36. return res;
  37. }
  38. #define main dummy_main
  39. int main(){
  40. return 0;
  41. }
  42. #undef main
  43. class Solution{
  44. public:
  45. vector<string> beforeAndAfterPuzzles(vector<string>& in){
  46. int i;
  47. int j;
  48. int k;
  49. int N;
  50. vector<string> a;
  51. vector<string> b;
  52. set<string> s;
  53. set<string>::iterator it;
  54. vector<string> res;
  55. N = in.size();
  56. for(i=0;i<(N);i++){
  57. for(j=0;j<(N);j++){
  58. if(i!=j){
  59. a =Explode_L(in[i], " ");
  60. b =Explode_L(in[j], " ");
  61. if(a[a.size()-1] == b[0]){
  62. for(k=(1);k<(b.size());k++){
  63. a.push_back(b[k]);
  64. }
  65. s.insert(Implode_L(a, " "));
  66. }
  67. }
  68. }
  69. }
  70. for(it=s.begin(); it!=s.end(); it++){
  71. res.push_back(*it);
  72. }
  73. return res;
  74. }
  75. }
  76. ;
  77. // cLay varsion 20190914-1
  78.  
  79. // --- original code ---
  80. // #define main dummy_main
  81. // {}
  82. // #undef main
  83. //
  84. // class Solution {
  85. // public:
  86. // vector<string> beforeAndAfterPuzzles(vector<string>& in) {
  87. // int i, j, k, N;
  88. // vector<string> a, b;
  89. // set<string> s;
  90. // set<string>::iterator it;
  91. // vector<string> res;
  92. //
  93. // N = in.size();
  94. // rep(i,N) rep(j,N) if(i!=j){
  95. // a = Explode(in[i], " ");
  96. // b = Explode(in[j], " ");
  97. // if(a[a.size()-1] == b[0]){
  98. // rep(k,1,b.size()) a.push_back(b[k]);
  99. // s.insert( Implode(a, " ") );
  100. // }
  101. // }
  102. //
  103. // for(it=s.begin(); it!=s.end(); it++) res.push_back(*it);
  104. // return res;
  105. // }
  106. // };
  107.  
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