Submission #336935

# Submission time Handle Problem Language Result Execution time Memory
336935 2020-12-17T12:00:58 Z kutbilim_one Red-blue table (IZhO19_stones) C++14
100 / 100
38 ms 2412 KB
/** @kutbilimone **/
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

void solve(){
	int n, m;
	cin >> n >> m;
	
	bool swapped = (n > m);
	char blue = '-', red = '+';                            
	if(n > m) swap(n, m), swap(blue, red);
	vector< vector<char> > a(n, vector<char> (m, blue));

	vector<int> col(m, n);
	int res = m; 
	for(int i = 0, j = 0; i < n; i++){
		for(int k = m/2+1, cntl = 0; k > 0; k--, j++){
			j %= m;
			if(col[j]-1 < n/2+1) continue;
			a[i][j] = red;
			cntl++;
			if(cntl == m/2+1) res++;
			col[j]--;
		}
	}

	cout << res << endl;
	for(int i = 0; i < (swapped ? m : n); i++){
		for(int j = 0; j < (swapped ? n : m); j++){
			cout << (swapped ? a[j][i] : a[i][j]);
		}
		cout << endl;
	}
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int t;
	cin >> t;
	while(t--){
		solve();
	}

	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1388 KB Output is correct
2 Correct 33 ms 1644 KB Output is correct
3 Correct 32 ms 1900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 1388 KB Output is correct
2 Correct 30 ms 1516 KB Output is correct
3 Correct 27 ms 1352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 38 ms 1388 KB Output is correct
6 Correct 33 ms 1644 KB Output is correct
7 Correct 32 ms 1900 KB Output is correct
8 Correct 37 ms 1388 KB Output is correct
9 Correct 30 ms 1516 KB Output is correct
10 Correct 27 ms 1352 KB Output is correct
11 Correct 9 ms 620 KB Output is correct
12 Correct 28 ms 1596 KB Output is correct
13 Correct 30 ms 1392 KB Output is correct
14 Correct 27 ms 1168 KB Output is correct
15 Correct 36 ms 2412 KB Output is correct
16 Correct 29 ms 1772 KB Output is correct
17 Correct 12 ms 1004 KB Output is correct