105152024-04-04 15:26:03111Egy trikolór mesterműcpp17Wrong answer 23/10018ms15748 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N,M,R,G,B;
	cin>>N>>M>>R>>G>>B;
	vector<vector<char>>g(N+1,vector<char>(M+1,'0'));
	vector<pair<int,char>>v{{R,'R'},{G,'G'},{B,'B'}};
	sort(v.rbegin(),v.rend());
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(i%2!=j%2){
				if(v[0].first){
					v[0].first--;
					g[i][j]=v[0].second;
				}
				else if(v[1].first){
					v[1].first--;
					g[i][j]=v[1].second;
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(i%2==j%2){
				if(v[1].first){
					v[1].first--;
					g[i][j]=v[1].second;
				}
				else if(v[2].first){
					v[2].first--;
					g[i][j]=v[2].second;
				}
			}
		}
	}
	int ok=1;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			ok&=g[i][j]!=g[i][j+1];
			ok&=g[i][j]!=g[i+1][j];
		}
	}
	if(!ok){
		cout<<"NO"<<'\n';
		return 0;
	}
	cout<<"YES"<<'\n';
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cout<<g[i][j];
		}
		cout<<'\n';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1824 KiB
2Accepted3ms2052 KiB
subtask20/17
3Accepted3ms2532 KiB
4Wrong answer2ms2508 KiB
5Accepted3ms2396 KiB
6Accepted3ms2592 KiB
7Accepted3ms2764 KiB
8Accepted3ms2852 KiB
9Accepted3ms2988 KiB
10Accepted3ms3212 KiB
11Accepted3ms3444 KiB
12Wrong answer3ms3660 KiB
subtask30/21
13Accepted6ms4220 KiB
14Accepted3ms4204 KiB
15Wrong answer3ms4216 KiB
16Wrong answer3ms4220 KiB
17Accepted3ms4364 KiB
subtask423/23
18Accepted6ms5012 KiB
19Accepted6ms5188 KiB
20Accepted3ms5140 KiB
21Accepted6ms5144 KiB
subtask50/39
22Accepted3ms4680 KiB
23Accepted13ms10088 KiB
24Accepted6ms4956 KiB
25Accepted6ms4964 KiB
26Accepted3ms4632 KiB
27Accepted6ms5100 KiB
28Accepted6ms5204 KiB
29Accepted18ms15748 KiB
30Accepted4ms5176 KiB
31Wrong answer3ms5332 KiB
32Accepted3ms4880 KiB