105212024-04-04 15:37:35111Egy trikolór mesterműcpp17Wrong answer 44/10067ms15212 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
1Wrong answer3ms1828 KiB
2Accepted3ms2064 KiB
subtask20/17
3Wrong answer3ms2260 KiB
4Accepted3ms2472 KiB
5Wrong answer2ms2560 KiB
6Accepted3ms2640 KiB
7Accepted3ms2648 KiB
8Accepted3ms2768 KiB
9Accepted3ms2888 KiB
10Accepted3ms3096 KiB
11Accepted3ms3184 KiB
12Accepted3ms3312 KiB
subtask321/21
13Accepted6ms3876 KiB
14Accepted59ms4084 KiB
15Accepted3ms3948 KiB
16Accepted3ms4072 KiB
17Accepted12ms4292 KiB
subtask423/23
18Accepted6ms4768 KiB
19Accepted6ms4728 KiB
20Accepted67ms4864 KiB
21Accepted6ms4720 KiB
subtask50/39
22Wrong answer3ms4260 KiB
23Accepted13ms9708 KiB
24Accepted6ms4484 KiB
25Accepted6ms4552 KiB
26Accepted3ms4240 KiB
27Accepted6ms4580 KiB
28Accepted6ms4476 KiB
29Accepted19ms15212 KiB
30Accepted4ms4476 KiB
31Wrong answer63ms4764 KiB
32Accepted3ms4320 KiB