Submission #342278

# Submission time Handle Problem Language Result Execution time Memory
342278 2021-01-01T17:32:35 Z SeDunion Red-blue table (IZhO19_stones) C++17
0 / 100
2000 ms 1388 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3 + 66;

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 + 1);
		int B = (Bcnt >= 1 ? Acnt / Bcnt : m);
		if (A + B >= ans) {
			ans = A + B;
			ai = A;
		}
	}
	cout << ans << "\n";
	vector<vector<char>> r(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 + 1);
		while (cnt--) {
			r[j][i] = '-';
			j++;
			if (j == n) 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 Correct 1 ms 364 KB Output is correct
2 Execution timed out 2080 ms 364 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2086 ms 364 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 2080 ms 364 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1388 KB in the table A+B is not equal to 294
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 1260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 2080 ms 364 KB Time limit exceeded