# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
463634 | fcmalkcin | Red-blue table (IZhO19_stones) | C++17 | 38 ms | 3144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops, no-stack-protector")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn=2e3+100;
const ll mod =1e9+7;
const ll base=3e18;
/// you will be the best but now you just are trash
/// goal 5/7
char ans[maxn][maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen("t.inp", "r"))
{
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll t;
cin>> t;
while (t--)
{
ll n, m;
ll res=0;
cin>> n>> m;
if (n+(m-1)/2>res)
{
res=n+(m-1)/2;
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
if (j<=m-(m-1)/2)
{
ans[i][j]='+';
}
else
{
ans[i][j]='-';
}
}
}
}
if (n>=(n%2?1:2)&&n-(n%2?1:2)+((m-1)/2)*2>res)
{
res=n-(n%2?1:2)+((m-1)/2)*2;
ll len=(m-1)/2;
ll len1=(n/2)+1;
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
if (i<=len1&&j<=len)
{
ans[i][j]='-';
}
else if (i>=n-len1+1&&j>=len+1&&j<=2*len)
{
ans[i][j]='-';
}
else
{
ans[i][j]='+';
}
// cout <<ans[i][j];
}
// cout <<endl;
}
}
if ((n-1)/2+m>res)
{
res=(n-1)/2+m;
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
if (i<=n-(n-1)/2)
{
ans[i][j]='-';
}
else
{
ans[i][j]='+';
}
}
}
}
if (m>=(m%2?1:2)&&m-(m%2?1:2)+((n-1)/2)*2>res)
{
res=m-(m%2?1:2)+((n-1)/2)*2;
// cout <<res<<endl;
ll len=(n-1)/2;
ll len1=(m/2)+1;
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
if (j<=len1&&i<=len)
{
ans[i][j]='+';
}
else if (j>=m-len1+1&&i>=len+1&&i<=2*len)
{
ans[i][j]='+';
}
else
{
ans[i][j]='-';
}
// cout <<ans[i][j];
}
// cout <<endl;
}
}
cout <<res<<endl;
for (int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++) cout <<ans[i][j];
cout <<endl;
}
}
}
Compilation message (stderr)
# | 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... |