Submission #384226

#TimeUsernameProblemLanguageResultExecution timeMemory
384226ritul_kr_singhRed-blue table (IZhO19_stones)C++17
28 / 100
33 ms1388 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' << 
#define nl << '\n'

bool e(int y){ return !(y%2); } // lol 

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	int T; cin >> T;
	while(T--){
		int n, m; cin >> n >> m;
		if(e(m) and ((e(n) and m > n) or !e(n))){
			cout << m + max(0LL, (n-1)/2) nl;
			for(int i=0; i<n; ++i){
				for(int j=0; j<m; ++j){
					cout << (i+i > n ? '+' : '-');
				}cout nl;
			}
		}else if(e(n)){
			cout << n + max(0LL, (m-1)/2) nl;
			for(int i=0; i<n; ++i){
				for(int j=0; j<m; ++j){
					cout << (j+j > m ? '-' : '+');
				}cout nl;
			}
		}else if(n==1){
			cout << m nl;
			for(int i=0; i<m; ++i) cout << '-';
			cout nl;
		}else if(m==1){
			cout << n nl;
			for(int i=0; i<n; ++i) cout << '+' nl;
		}else{
			cout << n + m - 2 nl;
			for(int i=0; i<n; ++i){
				for(int j=0; j<m; ++j){
					if(i and j) cout << ((i+j) % 2 ? '+' : '-');
					else cout << (i ? '+' : '-');
				}
				cout nl;
			}
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...