Submission #648171

# Submission time Handle Problem Language Result Execution time Memory
648171 2022-10-05T16:04:17 Z ymm Red-blue table (IZhO19_stones) C++17
100 / 100
34 ms 9228 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 2048;
int ans[N][N];
int n, m;

bool test(int x, int y)
{
	int have = ((m-1)/2) * (n-x) + (m-y)*x;
	int want = (n/2+1) * (m-y);
	return have >= want;
}

void make(int x, int y)
{
	Loop (i,0,x) Loop (j,0,m)
		ans[i][j] = 0;
	Loop (i,0,n) Loop (j,0,y)
		ans[i][j] = 1;
	int need = m/2+1 - y;
	int pos = 0;
	Loop (i,0,n-x) {
		Loop (j,0,m-y)
			ans[i+x][j+y] = 0;
		Loop (j,pos,pos+need)
			ans[i+x][j%(m-y)+y] = 1;
		pos += need;
	}
}

void solve()
{
	cin >> n >> m;
	for (int xy = 0;; ++xy) {
		for (int x = 0; x <= xy; ++x) {
			int y = xy-x;
			if (!test(x, y))
				continue;
			make(x, y);
			cout << n+m - xy << '\n';
			Loop (i,0,n) {
				Loop (j,0,m)
					cout << "-+"[::ans[i][j]];
				cout << '\n';
			}
			return;
		}
	}
}

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--)
		solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1648 KB Output is correct
2 Correct 34 ms 7116 KB Output is correct
3 Correct 25 ms 8700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1888 KB Output is correct
2 Correct 27 ms 6892 KB Output is correct
3 Correct 19 ms 3284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 29 ms 1648 KB Output is correct
6 Correct 34 ms 7116 KB Output is correct
7 Correct 25 ms 8700 KB Output is correct
8 Correct 24 ms 1888 KB Output is correct
9 Correct 27 ms 6892 KB Output is correct
10 Correct 19 ms 3284 KB Output is correct
11 Correct 9 ms 676 KB Output is correct
12 Correct 28 ms 4244 KB Output is correct
13 Correct 21 ms 4692 KB Output is correct
14 Correct 16 ms 3900 KB Output is correct
15 Correct 26 ms 9228 KB Output is correct
16 Correct 22 ms 7380 KB Output is correct
17 Correct 13 ms 3284 KB Output is correct