105172024-04-04 15:29:08111Egy trikolór mesterműcpp17Wrong answer 40/10017ms15256 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[2].first){
					v[2].first--;
					g[i][j]=v[2].second;
				}
				else{
					cout<<"NO"<<'\n';
					return 0;
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(i%2==j%2){
				if(v[2].first){
					v[2].first--;
					g[i][j]=v[2].second;
				}
				else if(v[1].first){
					v[1].first--;
					g[i][j]=v[1].second;
				}
				else{
					cout<<"NO"<<'\n';
					return 0;
				}
			}
		}
	}
	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
1Accepted3ms1832 KiB
2Accepted3ms2060 KiB
subtask217/17
3Accepted3ms2272 KiB
4Accepted3ms2484 KiB
5Accepted3ms2580 KiB
6Accepted3ms2564 KiB
7Accepted3ms2952 KiB
8Accepted3ms2832 KiB
9Accepted3ms2948 KiB
10Accepted3ms2980 KiB
11Accepted3ms3148 KiB
12Accepted3ms3376 KiB
subtask30/21
13Accepted6ms3600 KiB
14Accepted3ms3728 KiB
15Wrong answer3ms3852 KiB
16Wrong answer3ms3940 KiB
17Accepted3ms3812 KiB
subtask423/23
18Accepted6ms4268 KiB
19Accepted6ms4260 KiB
20Accepted3ms4260 KiB
21Accepted6ms4552 KiB
subtask50/39
22Accepted2ms3920 KiB
23Accepted12ms9380 KiB
24Accepted6ms4260 KiB
25Accepted6ms4360 KiB
26Accepted3ms4400 KiB
27Accepted6ms4372 KiB
28Accepted6ms4436 KiB
29Accepted17ms15256 KiB
30Accepted4ms4580 KiB
31Wrong answer3ms4652 KiB
32Accepted3ms4468 KiB