fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. string repeat(char c, int k){ return string(max(0,k),c); }
  5. string alt01(int k){ string s; for(int i=0;i<k;i++) s+="01"; return s; }
  6.  
  7. int main(){
  8. ios::sync_with_stdio(false);
  9. cin.tie(nullptr);
  10.  
  11. int a,b,c;
  12. cin >> a >> b >> c;
  13.  
  14. int x = max(0, a+b-c);
  15. int p = c - x;
  16. int q = a - x;
  17. int r = b - x;
  18.  
  19. string A = repeat('0',p) + repeat('1',r) + alt01(x);
  20. string B = repeat('0',p) + repeat('0',q) + alt01(x);
  21. string C = repeat('1',q) + repeat('1',r) + alt01(x);
  22.  
  23. cout << A << "\n" << B << "\n" << C << "\n";
  24. }
  25.  
Success #stdin #stdout 0.01s 5312KB
stdin
4 2 3
stdout
010101
0010101
1010101