This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |