Submission #474952

# Submission time Handle Problem Language Result Execution time Memory
474952 2021-09-20T10:58:48 Z fuad27 Red-blue table (IZhO19_stones) C++17
100 / 100
84 ms 2168 KB
#include<bits/stdc++.h>
using namespace std;
int main () {
	int t;
	cin >> t;
	while(t--) {
		char red = '+', blue = '-';
		int n, m;
		bool swapped = false;
		cin >> n >> m;
		if(n < m) {
			swap(n, m);
			swap(red, blue);
			swapped = true;
		}
		char table[n][m];
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<m;j++)table[i][j] = red;
		}
		int cnt = 0, ans = n;
		for(int asdf = 0;asdf<(m-1)/2;asdf++) {
			for(int i = 0;i<n;i++) {
				table[i][ans-n]=blue;
				cnt++;
				if(cnt == (n/2) + 1) {
					ans++;
					cnt = 0;
				}
			}
		}
		cout<<ans<<endl;
		if(!swapped) {
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<m;j++) {
				cout<<table[i][j];
			}
			cout<<endl;
		}
		}
		else {
		for(int i = 0;i<m;i++) {
			for(int j = 0;j<n;j++) {
				cout<<table[j][i];
			}
			cout<<endl;
		}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 8 ms 204 KB Output is correct
4 Correct 14 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 1252 KB Output is correct
2 Correct 50 ms 1732 KB Output is correct
3 Correct 39 ms 1732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 1220 KB Output is correct
2 Correct 38 ms 1604 KB Output is correct
3 Correct 37 ms 1292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 8 ms 204 KB Output is correct
4 Correct 14 ms 316 KB Output is correct
5 Correct 84 ms 1252 KB Output is correct
6 Correct 50 ms 1732 KB Output is correct
7 Correct 39 ms 1732 KB Output is correct
8 Correct 57 ms 1220 KB Output is correct
9 Correct 38 ms 1604 KB Output is correct
10 Correct 37 ms 1292 KB Output is correct
11 Correct 35 ms 432 KB Output is correct
12 Correct 35 ms 1400 KB Output is correct
13 Correct 39 ms 1336 KB Output is correct
14 Correct 29 ms 1076 KB Output is correct
15 Correct 43 ms 2168 KB Output is correct
16 Correct 33 ms 1604 KB Output is correct
17 Correct 15 ms 904 KB Output is correct