105192024-04-04 15:33:14111Egy trikolór mesterműcpp17Wrong answer 44/10017ms15032 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;
	for(int i=0;i<10;i++){
		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;
					}
				}
			}
		}
		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]!='0';
				ok&=g[i][j]!=g[i][j+1];
				ok&=g[i][j]!=g[i+1][j];
			}
		}
		if(ok){
			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;
		}
	}
	cout<<"NO"<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1880 KiB
2Accepted3ms2240 KiB
subtask20/17
3Accepted3ms2336 KiB
4Wrong answer3ms2404 KiB
5Accepted3ms2620 KiB
6Accepted3ms2828 KiB
7Accepted3ms2828 KiB
8Accepted3ms2808 KiB
9Accepted3ms3032 KiB
10Accepted3ms3264 KiB
11Accepted3ms3440 KiB
12Wrong answer3ms3648 KiB
subtask321/21
13Accepted6ms4232 KiB
14Accepted8ms4068 KiB
15Accepted3ms3980 KiB
16Accepted3ms3844 KiB
17Accepted3ms3904 KiB
subtask423/23
18Accepted6ms4552 KiB
19Accepted6ms4620 KiB
20Accepted8ms4768 KiB
21Accepted6ms4636 KiB
subtask50/39
22Accepted3ms4148 KiB
23Accepted12ms9732 KiB
24Accepted6ms4396 KiB
25Accepted6ms4448 KiB
26Accepted3ms4284 KiB
27Accepted6ms4460 KiB
28Accepted6ms4388 KiB
29Accepted17ms15032 KiB
30Accepted4ms4448 KiB
31Wrong answer8ms4624 KiB
32Accepted2ms4212 KiB