Language: C++

#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
//#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << #x <<": "<<x<<endl
#define debug2(x,y) cerr << #x <<": "<< x <<", "<< #y <<": "<< y << endl
#define answer(x) cout << x <<endl
#define answer_fixed(x, p) cout << fixed << setprecision(p) << x << endl
using namespace std;
//static const int INF = 1e9;
//static const double PI = acos(-1.0);
//static const double EPS = 1e-10;
//static const int dx[8] = { 1, 1, 0,-1,-1,-1, 0, 1};
//static const int dy[8] = { 0, 1, 1, 1, 0,-1,-1,-1};
typedef long long int LL;
typedef unsigned long long int ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef pair<int, int> PII;
/*** cout overload ***/
// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

enum Color{red, blue, green, yellow, undef};

struct Cell {
  enum Color deside = undef;
  set<enum Color> cand = {red, blue, green, yellow};
  bool r = true;
  bool g = true;
  bool b = true;
  bool y = true;
};
typedef vector<Cell> VCELL;
typedef vector<VCELL> VVCELL;

int main() {
  int H ,W, d;
  cin >> H >> W >> d;
  VVCELL cell(H, VCELL(W));

  cell[0][0].deside = red;
  REP(x, W) {
    REP(y, H) {
      debug2(x,y);
      enum Color cur_color = cell[y][x].deside;
      int dx = 0, dy = d;
      bool dir_x = 1, dir_y = 0;
      REP(k, 4 * d) {
        int nx = x + dx;
        if(nx < 0 || nx >= W) { continue; }
        int ny = y + dy;
        if(ny < 0 || ny >= H) { continue; }
        auto itr = cell[ny][nx].cand.find(cur_color);
        if(itr != cell[ny][nx].cand.end()) {
          cell[ny][nx].cand.erase(itr);
          REP(a, cell[ny][nx].cand.size()) {
          cout << *(cell[ny][nx].cand.begin() + a) << endl;
          }
        }
        if(cell[ny][nx].cand.size() == 1) {
          cell[ny][nx].deside = *cell[ny][nx].cand.begin();
        }
        dir_x ? dx++ : dx--;
        if(dx >= d || dx <= -d) { dir_x = !dir_x; }
        dir_y ? dy++ : dy--;
        if(dy >= d || dy <= -d) { dir_y = !dir_y; }
      }
    }
  }
  REP(x, W) {
    REP(y, H) {
      if(cell[y][x].deside == undef) {
        cell[y][x].deside = *cell[y][x].cand.begin();
      }
      switch(cell[y][x].deside) {
        case red : cout << 'R'; break;
        case blue : cout << 'G'; break;
        case green : cout << 'B'; break;
        case yellow : cout << 'Y'; break;
        default : cout << 'U';
      }
    }
    cout << endl;
   }
  return 0;
}


  /* ***use data_e for kruskal method***

  int kruskal(int V) {
    sort(all(data_e), comp_e);
    Union U(V);
    int res = 0;
    REP(i, N) {
      edge e = data_e[i];
      if(!U.find(e.u, e.v)) {
        U.unite(e.u, e.v);
        res += e.c;
      }
    }
    return res;
  }
  */

// complex
typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b){ return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b){ return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) {return b * dot_product(p,b) / norm(b);}

// GCD
int gcd(int a, int b) {
  if(b == 0) { return a; }
  return gcd(b, a % b);
}

// Prime
bool is_prime(int n) {
  for(int i = 2; i * i <= n; ++i) {
    if(n % i == 0) { return false; }
  }
  return n != 1;
}
VI divisor(int n) {
  VI res;
  for(int i = 1; i * i <= n; ++i) {
    if(n % i == 0) {
      res.pb(i);
      if(i != n / i) { res.pb(n / i); }
    }
  }
  return res;
}
map<int, int> prime_factor(int n) {
  map<int, int> res;
  for(int i = 2; i * i <= n; ++i) {
    while(n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if(n != 1) { res[n] = 1; }
  return res;
}
int sieve(int n) {
  VI prime;
  VB is_prime(n + 1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i <= n; ++i) {
    if(is_prime[i]) {
      prime.pb(i);
      for(int j = 2 * i; j <= n; j += i) { is_prime[j] = false; }
    }
  }
  return prime.size();
}

// Power
long long mod_pow(long long x, long long n, long long mod) {
  if(n == 0) { return 1; }
  long long res = mod_pow(x * x % mod, n >> 1, mod);
  if(n & 1) { res = res * x % mod; }
  return res;
}

// Binary search
double bi_search() {
  double lb = -1, ub = 1e9, ans;
  while (ub - lb > 0.001) {
    ans = (lb + ub) / 2;
    double C = 1; // hantei
    if (C) lb = ans;
    else ub = ans;
  }
  return ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:110:47: error: no match for 'operator+' (operand types are 'std::set<Color>::iterator' {aka 'std::_Rb_tree<Color, Color, std::_Identity<Color>, std::less<Color>, std::allocator<Color> >::const_iterator'} and 'int')
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
      |                                            |    |
      |                                            |    int
      |                                            std::set<Color>::iterator {aka std::_Rb_tree<Color, Color, std::_Identity<Color>, std::less<Color>, std::allocator<Color> >::const_iterator}
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
  627 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
 1798 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/istream:40,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from a.cc:4:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3598 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   'std::set<Color>::iterator' {aka 'std::_Rb_tree<Color, Color, std::_Identity<Color>, std::less<Color>, std::allocator<Color> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3616 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<Color>'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3635 |     operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3652 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   'std::set<Color>::iterator' {aka 'std::_Rb_tree<Color, Color, std::_Identity<Color>, std::less<Color>, std::allocator<Color> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
 3670 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   'std::set<Color>::iterator' {aka 'std::_Rb_tree<Color, Color, std::_Identity<Color>, std::less<Color>, std::allocator<Color> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3682 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   'std::set<Color>::iterator' {aka 'std::_Rb_tree<Color, Color, std::_Identity<Color>, std::less<Color>, std::allocator<Color> >::const_iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3689 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   'std::set<Color>::iterator' {aka 'std::_Rb_tree<Color, Color, std::_Identity<Color>, std::less<Color>, std::allocator<Color> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3696 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   'std::set<Color>::iterator' {aka 'std::_Rb_tree<Color, Color, std::_Identity<Color>, std::less<Color>, std::allocator<Color> >::const_iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3719 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<Color>'
  110 |           cout << *(cell[ny][nx].cand.begin() + a) << endl;
      |                                                 ^
/usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3726 |     operator+(_CharT __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3726:5: note:   template argument deduction/substitution failed:
a.cc:110:49: note:   mismatched types 'std::__cxx11::b