답안 #530854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530854 2022-02-27T01:50:26 Z abc864197532 Red-blue table (IZhO19_stones) C++17
100 / 100
24 ms 2252 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
	cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
	for (; l != r; ++l)
		cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x);
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false)
#endif
const int N = 200000;

int main () {
	owo;
	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		bool flag = false;
		if (n > m)
			flag = true, swap(n, m);
		int num = 0, ans = -1, now = m;
		vector <int> cnt(m, 0);
		for (int i = 0, j = 0; i <= n; ++i) {
			if (ans < now + i)
				ans = now + i, num = i;
			if (i == n)
				break;
			for (int c = 0; c < (m + 2) / 2; ++c, j = (j + 1) % m) {
				now -= cnt[j] < (n + 1) / 2;
				cnt[j]++;
				now += cnt[j] < (n + 1) / 2;
			}
		}
		cout << ans << endl;
		vector <string> s(n);
		for (int i = 0, j = 0; i < n; ++i) {
			string now = string(m, '-');
			if (i < num) {
				for (int c = 0; c < (m + 2) / 2; ++c, j = (j + 1) % m) {
					now[j] = '+';
				}
			}
			s[i] = now;
		}
		if (flag) {
			for (int i = 0; i < m; ++i) {
				for (int j = 0; j < n; ++j)
					cout << (s[j][i] == '+' ? '-' : '+');
				cout << '\n';
			}
		} else {
			for (int i = 0; i < n; ++i)
				cout << s[i] << '\n';
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 244 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1356 KB Output is correct
2 Correct 11 ms 1624 KB Output is correct
3 Correct 24 ms 1804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1356 KB Output is correct
2 Correct 6 ms 1460 KB Output is correct
3 Correct 5 ms 1196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 244 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
5 Correct 20 ms 1356 KB Output is correct
6 Correct 11 ms 1624 KB Output is correct
7 Correct 24 ms 1804 KB Output is correct
8 Correct 9 ms 1356 KB Output is correct
9 Correct 6 ms 1460 KB Output is correct
10 Correct 5 ms 1196 KB Output is correct
11 Correct 7 ms 460 KB Output is correct
12 Correct 20 ms 1436 KB Output is correct
13 Correct 19 ms 1240 KB Output is correct
14 Correct 12 ms 1012 KB Output is correct
15 Correct 7 ms 2252 KB Output is correct
16 Correct 5 ms 1740 KB Output is correct
17 Correct 9 ms 972 KB Output is correct