Advertisement
erfanul007

Untitled

Jan 23rd, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scl(n) scanf("%lld",&n)
  17. #define scf(n) scanf("%lf",&n)
  18. #define scs(s) scanf("%s",s)
  19. #define pfi(n) printf("%d",n)
  20. #define pfl(n) printf("%lld",n)
  21. #define pff(n) cout<<n
  22. #define line printf("\n")
  23. #define spc printf(" ")
  24. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  25. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  26. #define cspf(i) printf("Case %d: ", i)
  27. #define pb push_back
  28. #define mp make_pair
  29. #define ff first
  30. #define ss second
  31. #define all(v) v.begin(),v.end()
  32. #define rall(v) v.rbegin(),v.rend()
  33. #define read() freopen("input.txt", "r", stdin)
  34. #define write() freopen("output.txt", "w", stdout)
  35. /// Constants
  36. #define eps 1e-9
  37. #define PI acos(-1.0) // 3.1415926535897932
  38.  
  39. int main()
  40. {
  41. int n;
  42. sci(n);
  43. string s[10],st;
  44. cin>>s[0];
  45. s[1]=s[0];
  46. s[2]=s[0];
  47. s[3]=s[0];
  48. s[4]=s[0];
  49. s[5]=s[0];
  50. s[6]=s[0];
  51. int cnt[10],c;
  52. loop(i,0,8) cnt[i]=0;
  53. //1
  54. loop(i,0,n-1){
  55. if(i%3==0){
  56. s[1][i]='R';
  57. if(s[1][i]!=s[0][i])
  58. cnt[1]++;
  59. }
  60. else if(i%3==1){
  61. s[1][i]='G';
  62. if(s[1][i]!=s[0][i])
  63. cnt[1]++;
  64. }
  65. else{
  66. s[1][i]='B';
  67. if(s[1][i]!=s[0][i])
  68. cnt[1]++;
  69. }
  70. }
  71. //2
  72. loop(i,0,n-1){
  73. if(i%3==0){
  74. s[2][i]='R';
  75. if(s[2][i]!=s[0][i])
  76. cnt[2]++;
  77. }
  78. else if(i%3==1){
  79. s[2][i]='B';
  80. if(s[2][i]!=s[0][i])
  81. cnt[2]++;
  82. }
  83. else{
  84. s[2][i]='G';
  85. if(s[2][i]!=s[0][i])
  86. cnt[2]++;
  87. }
  88. }
  89. //3
  90. loop(i,0,n-1){
  91. if(i%3==0){
  92. s[3][i]='G';
  93. if(s[3][i]!=s[0][i])
  94. cnt[3]++;
  95. }
  96. else if(i%3==1){
  97. s[3][i]='R';
  98. if(s[3][i]!=s[0][i])
  99. cnt[3]++;
  100. }
  101. else{
  102. s[3][i]='B';
  103. if(s[3][i]!=s[0][i])
  104. cnt[3]++;
  105. }
  106. }
  107. //4
  108. loop(i,0,n-1){
  109. if(i%3==0){
  110. s[4][i]='G';
  111. if(s[4][i]!=s[0][i])
  112. cnt[4]++;
  113. }
  114. else if(i%3==1){
  115. s[4][i]='B';
  116. if(s[4][i]!=s[0][i])
  117. cnt[4]++;
  118. }
  119. else{
  120. s[4][i]='R';
  121. if(s[4][i]!=s[0][i])
  122. cnt[4]++;
  123. }
  124. }
  125. //5
  126. loop(i,0,n-1){
  127. if(i%3==0){
  128. s[5][i]='B';
  129. if(s[5][i]!=s[0][i])
  130. cnt[5]++;
  131. }
  132. else if(i%3==1){
  133. s[5][i]='R';
  134. if(s[5][i]!=s[0][i])
  135. cnt[5]++;
  136. }
  137. else{
  138. s[5][i]='G';
  139. if(s[5][i]!=s[0][i])
  140. cnt[5]++;
  141. }
  142. }
  143. //6
  144. loop(i,0,n-1){
  145. if(i%3==0){
  146. s[6][i]='B';
  147. if(s[6][i]!=s[0][i])
  148. cnt[6]++;
  149. }
  150. else if(i%3==1){
  151. s[6][i]='G';
  152. if(s[6][i]!=s[0][i])
  153. cnt[6]++;
  154. }
  155. else{
  156. s[6][i]='R';
  157. if(s[6][i]!=s[0][i])
  158. cnt[6]++;
  159. }
  160. }
  161. int mn = 999999;
  162. loop(i,1,6){
  163. if(mn>cnt[i]){
  164. mn=cnt[i];
  165. st=s[i];
  166. }
  167. }
  168. pfi(mn);line;
  169. cout<<st<<endl;
  170. return 0;
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement