제출 #1222116

#제출 시각아이디문제언어결과실행 시간메모리
1222116thangdz2k7Red-blue table (IZhO19_stones)C++20
0 / 100
30 ms1352 KiB
#include <bits/stdc++.h>

using namespace std;

void process(){
	int n, m; cin >> n >> m;
	int swapped = 0;
	if (n < m){
		swap(n, m);
		swapped = 1;
	}

	vector <string> s(n);
	for (int i = 0; i < n; ++ i)
		for (int j = 0; j < m; ++ j)
			s[i] = s[i] + '+';


	int res = n;
	vector <int> cnt(m, 0);
	for (int i = 0; i < n; ++ i){
		int cur = 0;
		for (int j = 0; j < m; ++ j){
			if (cur + 1 >= (m + 1) / 2) break;
			if (cnt[j] >= (n + 1) / 2) continue;
			s[i][j] = '-';
			cnt[j] ++, cur ++;
		}
	}

	for (int j = 0; j < m; ++ j)
		res += (cnt[j] > n / 2);

	cout << res << "\n";

	if (!swapped){
		for (int i = 0; i < n; ++ i) 
			cout << s[i] << "\n";
		return;
	}

	for (int j = 0; j < m; ++ j){
		for (int i = 0; i < n; ++ i) 
			if (s[i][j] == '+') cout << '-';
			else cout << '+';
		cout << "\n";
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int t; cin >> t; while (t --) 
	process();

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