Submission #502052

# Submission time Handle Problem Language Result Execution time Memory
502052 2022-01-05T07:18:08 Z Mazaalai Red-blue table (IZhO19_stones) C++17
100 / 100
36 ms 2220 KB
#include <bits/stdc++.h> 
#define pb push_back
#define ALL(x) x.begin(),x.end()
using namespace std;
int n, m;
string s = "+-";
const int N = 1e3+1;
char ans[N][N];
void go() {
	bool flip = 0;
	cin >> n >> m;
	if (n > m) {
		flip = 1;
		swap(n, m);
		reverse(ALL(s));
	}
	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++) ans[i][j] = s[1];
	int changeCnt = m * ((n-1)/2), curLine = 0, curPick = 0;
	for (int i = 0; changeCnt>0; i++) {
		ans[curLine][i%m] = s[0];
		changeCnt--, curPick++;
		if (curPick*2 > m) {
			curLine++;
			curPick = 0;
		}
	}
	cout << m + curLine <<'\n';
	if (flip) swap(n, m), reverse(ALL(s));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) cout << (flip ? ans[j][i] : ans[i][j]);
		cout << '\n';
	}
}
signed main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	int T; cin >> T;
	while(T--) go();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1304 KB Output is correct
2 Correct 29 ms 1860 KB Output is correct
3 Correct 29 ms 1788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1384 KB Output is correct
2 Correct 26 ms 1732 KB Output is correct
3 Correct 24 ms 1576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 36 ms 1304 KB Output is correct
6 Correct 29 ms 1860 KB Output is correct
7 Correct 29 ms 1788 KB Output is correct
8 Correct 32 ms 1384 KB Output is correct
9 Correct 26 ms 1732 KB Output is correct
10 Correct 24 ms 1576 KB Output is correct
11 Correct 9 ms 460 KB Output is correct
12 Correct 25 ms 1584 KB Output is correct
13 Correct 27 ms 1572 KB Output is correct
14 Correct 20 ms 1236 KB Output is correct
15 Correct 32 ms 2220 KB Output is correct
16 Correct 23 ms 1756 KB Output is correct
17 Correct 11 ms 1064 KB Output is correct