Submission #530853

# Submission time Handle Problem Language Result Execution time Memory
530853 2022-02-27T01:48:34 Z abc864197532 Red-blue table (IZhO19_stones) C++17
11 / 100
22 ms 1860 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;
		assert(n & 1 && m & 1);
		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 + 1) / 2; ++c, j = (j + 1) % m) {
				now -= cnt[j] <= n / 2;
				cnt[j]++;
				now += cnt[j] <= n / 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 + 1) / 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';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1356 KB Output is correct
2 Correct 11 ms 1592 KB Output is correct
3 Correct 22 ms 1860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -