105162024-04-04 15:27:09111Egy trikolór mesterműcpp17Wrong answer 40/10017ms14304 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;
				}
			}
		}
	}
	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;
				}
			}
		}
	}
	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
2Accepted3ms2060 KiB
subtask217/17
3Accepted3ms2232 KiB
4Accepted3ms2468 KiB
5Accepted2ms2532 KiB
6Accepted3ms2660 KiB
7Accepted3ms2868 KiB
8Accepted2ms2952 KiB
9Accepted2ms2948 KiB
10Accepted3ms3096 KiB
11Accepted3ms3148 KiB
12Accepted3ms3232 KiB
subtask30/21
13Accepted6ms3624 KiB
14Accepted3ms3472 KiB
15Wrong answer3ms3296 KiB
16Wrong answer3ms3292 KiB
17Accepted3ms3292 KiB
subtask423/23
18Accepted6ms4008 KiB
19Accepted6ms3972 KiB
20Accepted3ms3964 KiB
21Accepted6ms3964 KiB
subtask50/39
22Accepted3ms3488 KiB
23Accepted12ms8932 KiB
24Accepted6ms3728 KiB
25Accepted6ms3724 KiB
26Accepted3ms3480 KiB
27Accepted6ms3872 KiB
28Accepted6ms3828 KiB
29Accepted17ms14304 KiB
30Accepted4ms3720 KiB
31Wrong answer3ms4132 KiB
32Accepted3ms3696 KiB