답안 #342434

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342434 2021-01-02T06:19:39 Z SeDunion Red-blue table (IZhO19_stones) C++17
100 / 100
50 ms 2412 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3 + 66;
	
vector<vector<char>> r;

void solve() {
	int n, m;
	cin >> n >> m;
	int ans = 0, ai = 0, bi = 0;
	for (int A = 0 ; A <= n ; ++ A) {
		int Acnt = ((m - 1) / 2) * A; // not A * (m-1) / 2!!!!!!!!!!!!!!!!
		int Bcnt = ((A * 2 - n) / 2 + 1);
		int B = (A * 2 - n >= 0 ? Acnt / Bcnt : m);
		B = min(B, m);
		if (A + B >= ans) {
			ans = A + B;
			ai = A;
			bi = B;
		}
	}
	cout << ans << "\n";
	r = vector<vector<char>>(n, vector<char>(m, '-'));
	for (int i = 0 ; i < ai ; ++ i) {
		r[i] = vector<char>(m, '+');
	}
	for (int i = 0, j = 0 ; ai != 0 && i < bi ; ++ i) {
		int cnt = ai * 2 - n;
		while (cnt >= 0) {
			cnt -= 2;
			r[j][i] = '-';
			j++;
			if (j == ai) j = 0;
		}
	}
	for (auto &vec : r) {
		for (char &i : vec) cout << i;
		cout << "\n";
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 1388 KB Output is correct
2 Correct 34 ms 2284 KB Output is correct
3 Correct 33 ms 2028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1388 KB Output is correct
2 Correct 31 ms 1772 KB Output is correct
3 Correct 29 ms 1772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 41 ms 1388 KB Output is correct
6 Correct 34 ms 2284 KB Output is correct
7 Correct 33 ms 2028 KB Output is correct
8 Correct 39 ms 1388 KB Output is correct
9 Correct 31 ms 1772 KB Output is correct
10 Correct 29 ms 1772 KB Output is correct
11 Correct 13 ms 620 KB Output is correct
12 Correct 29 ms 1644 KB Output is correct
13 Correct 30 ms 1772 KB Output is correct
14 Correct 23 ms 1388 KB Output is correct
15 Correct 50 ms 2412 KB Output is correct
16 Correct 27 ms 1772 KB Output is correct
17 Correct 13 ms 1004 KB Output is correct