Submission #209909

#TimeUsernameProblemLanguageResultExecution timeMemory
209909super_j6Red-blue table (IZhO19_stones)C++14
0 / 100
32 ms1400 KiB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

int n, m;

void answer(){
	cin >> n >> m;
	
	int t;
	if(n < m){
		t = (n - 1) / 2;
		cout << (m + t) << endl;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cout << (i < t ? '+' : '-');
			}
			cout << endl;
		}
	}else if(n > m || (n == m && n % 2 == 0)){
		t = (m - 1) / 2;
		cout << (n + t) << endl;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cout << (j < t ? '-' : '+');
			}
			cout << endl;
		}
	}else{
		t = (n - 1) / 2;
		cout << (4 * t) << endl;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(i < t && j < m - t) cout << '+';
				else if(i > n - t - 1 && j > t - 1) cout << '+';
				else cout << '-';
			}
			cout << endl;
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int t;
	cin >> t;
	
	for(int i = 0; i < t; i++) answer();

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