fork download
  1.  
  2. #include<iostream>
  3. using namespace std;
  4. #include<map>
  5.  
  6. map<long long, long long> first, second;
  7. string str1, str2, res;
  8.  
  9. string camp_schedule(){
  10.  
  11. for(auto c: str1){
  12. if(c == '0')
  13. first[0]++;
  14. else if(c == '1')
  15. first[1]++;
  16. }
  17. for(auto c: str2){
  18. if(c == '0')
  19. second[0]++;
  20. else if(c == '1')
  21. second[1]++;
  22. }
  23.  
  24. if(first[0] < second[0] || first[1] < second[1]){
  25. return str1;
  26. }
  27.  
  28. long long div1 = first[0] / second[0];
  29. long long div2 = first[1] / second[1];
  30.  
  31. long long minm = min(div1, div2);
  32. string str = "";
  33.  
  34. //cout<<"\n\nminimum is "<<minm;
  35. long long temp = minm;
  36.  
  37. while(minm--){
  38. str += str2;
  39. }
  40. //cout<<"\n\nafter adding minm str = "<<str;
  41.  
  42. first[0] -= (temp * second[0]);
  43. first[1] -= (temp * second[1]);
  44.  
  45. //cout<<"\n\nafter subtracting first[0] = "<<first[0];
  46. //cout<<"\n\nafter subtracting first[1] = "<<first[1]<<"\n\n";
  47.  
  48. while(first[0]--){
  49. str += "0";
  50. }
  51.  
  52. while(first[1]--){
  53. str += "1";
  54. }
  55. return str;
  56. }
  57. int main(){
  58.  
  59. ios::sync_with_stdio(0);
  60.  
  61. cin>>str1;
  62. cin>>str2;
  63.  
  64. res = camp_schedule();
  65. cout<<res<<"\n";
  66.  
  67. return 0;
  68. }
  69.  
Runtime error #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty