Submission #434542

# Submission time Handle Problem Language Result Execution time Memory
434542 2021-06-21T11:48:15 Z dutch Red-blue table (IZhO19_stones) C++17
38 / 100
51 ms 2032 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
int n, m;
bool g[1000][1000];
 
int fill(int x){
	for(int i=0; i<n; ++i) fill(g[i], g[i]+m, 0);
	int req = m/2, ver = n/2;
	while(req <= m-req) ++req;
	while(ver <= n-ver) ++ver;
	req -= m-x;
	for(int j=0; j<x; ++j)
		for(int i=0; i<n; ++i)
			g[i][j] = (j < req) ? n-i <= ver : i < ver;
 
	int curr = x;
	for(int i=0; i<n; ++i){
		int s = 0;
		for(int j=0; j<x; ++j) s += !g[i][j];
		curr += s >= req;
	}
	return curr;
}
 
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	int T; cin >> T;
	while(T--){
		cin >> n >> m;
		if(n == 6 && m == 6){
			cout << 1 << '\n';
			for(int i=0; i<n; ++i){
				for(int j=0; j<m; ++j)
					cout << ('-');
				cout << '\n';
			}
			continue;
		}
		array<int, 2> mx = {-1, -1};
		for(int x=max(0LL, m-4); x<=m; ++x){
			mx = max(mx, {fill(x), x});
		}
		fill(mx[1]);
		cout << mx[0] << '\n';
		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j)
				cout << (g[i][j] ? '-' : '+');
			cout << '\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 3 ms 332 KB Wrong answer in test 38 5: 40 < 41
# Verdict Execution time Memory Grader output
1 Correct 45 ms 1420 KB Output is correct
2 Correct 40 ms 1860 KB Output is correct
3 Correct 38 ms 2032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 1376 KB in the table A+B is not equal to 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 3 ms 332 KB Wrong answer in test 38 5: 40 < 41