Submission #223786

# Submission time Handle Problem Language Result Execution time Memory
223786 2020-04-16T12:44:57 Z socho Red-blue table (IZhO19_stones) C++14
27 / 100
82 ms 1400 KB
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define double long double
// #define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

void solve() {
	
	int n, m;
	cin >> n >> m;
	
	bool grid[n][m]; // 1 is +, 0 is -
	memset(grid, 1, sizeof grid);
	
	int best = n;
	int bX = n;
	int bA = m;
	
	for (int x=0; x<=n; x++) {
		int y = n - x;
		for (int a=0; a<=m; a++) {
			int b = m - a;
			
			int ans = 0;
			if (x > y) {
				ans += b;
			}
			else if (y > x) {
				ans += a;
			}
			if (a > b) {
				ans += x;
			}
			else if (b > a) {
				ans += y;
			}
			
			if (ans > best) {
				best = ans;
				bX = x;
				bA = a;
			}
			
		}
	}
	
	for (int i=0; i<bX; i++) {
		for (int j=bA; j<m; j++) {
			grid[i][j] = 0;
		}
	}
	for (int i=bX; i<n; i++) {
		for (int j=0; j<bA; j++) {
			grid[i][j] = 0;
		}
	}
	
	cout << best << endl;
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			if (grid[i][j]) cout << '+';
			else cout << '-';
		}
		cout << endl;
	}
	
}

signed main() {
	
	int t;
	cin >> t;
	while (t--) solve();
	
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Incorrect 20 ms 384 KB Wrong answer in test 5 29: 31 < 32
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 1400 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 1400 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Incorrect 20 ms 384 KB Wrong answer in test 5 29: 31 < 32