Submission #336935

#TimeUsernameProblemLanguageResultExecution timeMemory
336935kutbilim_oneRed-blue table (IZhO19_stones)C++14
100 / 100
38 ms2412 KiB
/** @kutbilimone **/
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

void solve(){
	int n, m;
	cin >> n >> m;
	
	bool swapped = (n > m);
	char blue = '-', red = '+';                            
	if(n > m) swap(n, m), swap(blue, red);
	vector< vector<char> > a(n, vector<char> (m, blue));

	vector<int> col(m, n);
	int res = m; 
	for(int i = 0, j = 0; i < n; i++){
		for(int k = m/2+1, cntl = 0; k > 0; k--, j++){
			j %= m;
			if(col[j]-1 < n/2+1) continue;
			a[i][j] = red;
			cntl++;
			if(cntl == m/2+1) res++;
			col[j]--;
		}
	}

	cout << res << endl;
	for(int i = 0; i < (swapped ? m : n); i++){
		for(int j = 0; j < (swapped ? n : m); j++){
			cout << (swapped ? a[j][i] : a[i][j]);
		}
		cout << endl;
	}
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int t;
	cin >> t;
	while(t--){
		solve();
	}

	return 0;
}

#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...