Submission #342288

# Submission time Handle Problem Language Result Execution time Memory
342288 2021-01-01T17:49:36 Z SeDunion Red-blue table (IZhO19_stones) C++17
0 / 100
38 ms 1536 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3 + 66;
	
vector<vector<char>> r;

void solve() {
	int n, m;
	cin >> n >> m;
	int ans = 0, ai = 0;
	for (int A = 0 ; A <= n ; ++ A) {
		int Acnt = ((m - 1) / 2) * A; // not A * (m-1) / 2!!!!!!!!!!!!!!!!
		int Bcnt = ((A * 2 - n) / 2 + 1);
		int B = (Bcnt >= 1 ? Acnt / Bcnt : m);
		if (A + B >= ans) {
			ans = A + B;
			ai = A;
		}
	}
	cout << ans << "\n";
	r = vector<vector<char>>(n, vector<char>(m, '-'));
	for (int i = 0 ; i < ai ; ++ i) {
		r[i] = vector<char>(m, '+');
	}
	for (int i = 0, j = 0 ; i < m ; ++ i) {
		int cnt = ((ai * 2 - n) / 2 + 1);
		while (cnt-- > 0) {
			r[j][i] = '-';
			j++;
			if (j == ai) j = 0;
		}
	}
	for (auto &vec : r) {
		for (char &i : vec) cout << i;
		cout << "\n";
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB in the table A+B is not equal to 2
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1388 KB in the table A+B is not equal to 539
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 1536 KB in the table A+B is not equal to 144
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -