105182024-04-04 15:31:21111Egy trikolór mesterműcpp17Wrong answer 23/10017ms14444 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'}};
	random_shuffle(v.begin(),v.end());
	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 if(v[1].first){
					v[1].first--;
					g[i][j]=v[1].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
1Accepted3ms1828 KiB
2Accepted3ms2052 KiB
subtask20/17
3Accepted3ms2260 KiB
4Wrong answer3ms2340 KiB
5Wrong answer2ms2416 KiB
6Accepted2ms2412 KiB
7Accepted2ms2416 KiB
8Accepted2ms2416 KiB
9Wrong answer2ms2416 KiB
10Accepted2ms2520 KiB
11Accepted3ms2548 KiB
12Wrong answer2ms2648 KiB
subtask30/21
13Accepted6ms3108 KiB
14Accepted3ms3212 KiB
15Accepted3ms3084 KiB
16Wrong answer3ms3084 KiB
17Accepted3ms3084 KiB
subtask423/23
18Accepted6ms3544 KiB
19Accepted6ms3544 KiB
20Accepted3ms3536 KiB
21Accepted6ms3676 KiB
subtask50/39
22Accepted2ms3164 KiB
23Accepted12ms8680 KiB
24Accepted6ms3508 KiB
25Accepted6ms3708 KiB
26Accepted3ms3468 KiB
27Accepted6ms3704 KiB
28Accepted6ms3716 KiB
29Accepted17ms14444 KiB
30Accepted4ms3716 KiB
31Wrong answer3ms3780 KiB
32Accepted2ms3476 KiB