fork(2) download
  1. #include <bits/stdc++.h>
  2. #define mp make_pair
  3. #define pb push_back
  4. using namespace std;
  5. typedef long long ll;
  6. typedef pair<int,int> pii;
  7. typedef pair<ll,ll> pll;
  8. typedef long double ld;
  9. typedef map<ll,ll>::iterator mapit;
  10. typedef set<int>::iterator setit;
  11. const int maxn = 100+4;
  12. const ll inf=1e18;
  13. const int mod=1e9+7;
  14. int x[3] , y[3];
  15. char c[3];
  16. int main()
  17. {
  18. ios_base::sync_with_stdio(0);cin.tie(0);cout.precision(20);cout.tie(0);
  19. cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
  20. int s = x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
  21. c[0] = 'A' , c[1] = 'B' , c[2] = 'C';
  22. int l = sqrt(s);
  23. if(l * l !=s)
  24. {
  25. cout << -1;
  26. return 0;
  27. }
  28. for(int i=0;i<3;i++)
  29. if(x[i] > l || y[i] > l)
  30. {
  31. cout << -1;
  32. return 0;
  33. }
  34. vector<int> v;
  35. for(int i=0;i<3;i++)
  36. {
  37. if(y[i] == l)
  38. swap(x[i],y[i]);
  39. if(x[i] == l)
  40. v.pb(i);
  41. }
  42. if(v.size() == 3)
  43. {
  44. cout << l << endl;
  45. for(int i=0;i<3;i++)
  46. {
  47. for(int j=0;j<y[i];j++)
  48. {
  49. for(int k=0;k<l;k++)
  50. cout << c[i] ;
  51. cout << endl;
  52. }
  53. }
  54. return 0;
  55. }
  56. if(v.size() == 1)
  57. {
  58. int cur = y[v[0]];
  59. int le = l - cur;
  60. int co = 0;
  61. for(int i=0;i<3;i++)
  62. {
  63. if(i != v[0])
  64. {
  65. if(y[i] == le)
  66. swap(x[i] , y[i]);
  67. if(x[i] == le)
  68. co ++;
  69. }
  70. }
  71. if(co == 2)
  72. {
  73. cout << l << endl;
  74. for(int i=0;i<cur;i++)
  75. {
  76. for(int j=0;j<l;j++)
  77. cout << c[v[0]];
  78. cout << endl;
  79. }
  80. int o1 = (v[0] + 1) % 3;
  81. int o2 = (o1 + 1) % 3;
  82. for(int i=0;i<le;i++)
  83. {
  84. for(int j=0;j<y[o1];j++)
  85. cout << c[o1];
  86. for(int j=0;j<y[o2];j++)
  87. cout << c[o2];
  88. cout << endl;
  89. }
  90. return 0;
  91. }
  92. }
  93. cout << -1 ;
  94. return 0;
  95. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
0