105202024-04-04 15:33:58111Egy trikolór mesterműcpp17Wrong answer 61/10067ms15456 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<100;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;
					}
				}
			}
		}
		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
1Accepted3ms1828 KiB
2Accepted3ms2052 KiB
subtask217/17
3Accepted3ms2284 KiB
4Accepted3ms2496 KiB
5Accepted3ms2840 KiB
6Accepted3ms2764 KiB
7Accepted3ms2756 KiB
8Accepted3ms2844 KiB
9Accepted3ms2980 KiB
10Accepted3ms3316 KiB
11Accepted3ms3468 KiB
12Accepted3ms3548 KiB
subtask321/21
13Accepted6ms3900 KiB
14Accepted59ms3936 KiB
15Accepted3ms3732 KiB
16Accepted3ms3988 KiB
17Accepted10ms3936 KiB
subtask423/23
18Accepted6ms4400 KiB
19Accepted6ms4408 KiB
20Accepted67ms4552 KiB
21Accepted6ms4396 KiB
subtask50/39
22Accepted3ms4040 KiB
23Accepted13ms9752 KiB
24Accepted6ms4568 KiB
25Accepted6ms4812 KiB
26Accepted3ms4560 KiB
27Accepted6ms4804 KiB
28Accepted6ms4864 KiB
29Accepted19ms15456 KiB
30Accepted4ms4868 KiB
31Wrong answer61ms5148 KiB
32Accepted3ms4616 KiB