Submission #342280

# Submission time Handle Problem Language Result Execution time Memory
342280 2021-01-01T17:36:36 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;
	
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 + 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 + 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 2091 ms 384 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2072 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 2091 ms 384 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 37 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 2081 ms 1132 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 2091 ms 384 KB Time limit exceeded