fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define mp make_pair
  4. #define pb(a) push_back(a)
  5. #define pp pop_back()
  6. #define all(v) (v.begin(), v.end())
  7. #define alar (a + 1, a + 1 + n)
  8. #define ff first
  9. #define ss second
  10. #define sz(a) (int)(a.size())
  11.  
  12. #define rep(i, d, e) for (int i = d; i < e; i++)
  13. #define ffor(i, a, b) for (int i = a; i <= b; i++)
  14. #define rloop(i, c, d) for (int i = c; i >= d; i--)
  15.  
  16. #define ll long long
  17. #define vc vector<ll>
  18. #define pii pair<ll, ll>
  19. #define mii map<ll, ll>
  20.  
  21. #define bestsort sort(a.begin(), a.end(), [](ll x, ll y) { return abs(x) > abs(y); })
  22. #define mod 1000000007
  23. #define MAX 300005
  24. #define endl "\n"
  25. #define o(x) cout << x << endl
  26. using namespace std;
  27. const int N = 1e5 + 10;
  28.  
  29. void solve()
  30.  
  31. {
  32. int r, g, b;
  33. cin >> r >> g >> b;
  34. int n = r + g + b;
  35. string s;
  36.  
  37.  
  38. if (r +g<b)
  39. {
  40. cout << -1 << endl;
  41. return;
  42. }
  43.  
  44.  
  45. vector<pii>v;
  46.  
  47. int rr = r - 1, bb = b - 1, gg = g - 1;
  48. if(gg<rr)
  49. swap(rr,gg);
  50.  
  51.  
  52.  
  53.  
  54. s += 'R', s += 'G', s += 'B';
  55. v.pb(mp(1,2));
  56. v.pb(mp(2,3));
  57. int i = 4;
  58.  
  59. while (i <= n)
  60. {
  61. if(bb==1)
  62. {
  63. s+= 'B';
  64. bb--;
  65. v.pb(mp(1,i));
  66. }
  67. else
  68. {
  69. if (gg > 0)
  70. {
  71. s += 'G', gg--;
  72. v.pb(mp(1,i));
  73. }
  74. if (bb > 0)
  75. {
  76. i++;
  77. s+= 'B';
  78. bb--;
  79. v.pb(mp(i-1,i));
  80. }
  81. }
  82.  
  83. i++;
  84. if((bb|gg)==0) break;
  85. }
  86.  
  87. // remaining R's
  88. while (rr > 0)
  89. {
  90. s += 'R';
  91. v.pb(mp(1,i));
  92. i++;
  93. rr--;
  94. }
  95. // If number of R>G then we swap R to G and G to R
  96. if(g<r)
  97. {
  98. ffor(i,0,sz(s)-1)
  99. {
  100. if(s[i]=='R')
  101. s[i]='G';
  102. else if(s[i]=='G')
  103. s[i]='R';
  104. }
  105. }
  106.  
  107. // print the answer
  108. cout << s << endl;
  109.  
  110. ffor(i,0,sz(v)-1)
  111. {
  112. cout<<v[i].ff<<" "<<v[i].ss<<endl;
  113. }
  114. }
  115.  
  116.  
  117. int main()
  118. {
  119. ios_base::sync_with_stdio(false);
  120.  
  121. cin.tie(NULL);
  122. cout.tie(NULL);
  123.  
  124. int t;
  125. cin >> t;
  126. ffor(j, 1, t)
  127. {
  128. solve();
  129. }
  130. }
Runtime error #stdin #stdout 1.47s 2095780KB
stdin
Standard input is empty
stdout
Standard output is empty