| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1358344 | ivaziva | Red-blue table (IZhO19_stones) | C++20 | 14 ms | 1524 KiB |
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1001
int t,n,m;
char a[MAXN][MAXN];
int main()
{
cin>>t;
for (int test=0;test<t;test++)
{
cin>>n>>m;
if (min(n,m)==n and n==5)
{
for (int row=1;row<=n;row++)
{
for (int col=1;col<=m;col++) a[row][col]='+';
}
for (int col=1;col<=m;col++) a[1][col]=a[2][col]='-';
int curr=3;
for (int col=1;col<=m;col++)
{
a[curr][col]='-';curr++;
if (curr==6) curr=3;
}
cout<<n+m-2<<endl;
for (int row=1;row<=n;row++)
{
for (int col=1;col<=m;col++) cout<<a[row][col];
cout<<endl;
}
continue;
}
else if (min(n,m)==m and m==5)
{
for (int row=1;row<=n;row++)
{
for (int col=1;col<=m;col++) a[row][col]='-';
}
for (int row=1;row<=n;row++) a[row][1]=a[row][2]='+';
int curr=3;
for (int row=1;row<=n;row++)
{
a[row][curr]='+';curr++;
if (curr==6) curr=3;
}
cout<<n+m-2<<endl;
for (int row=1;row<=n;row++)
{
for (int col=1;col<=m;col++) cout<<a[row][col];
cout<<endl;
}
continue;
}
else if (min(n,m)<5)
{
if (n<=m)
{
int targeta=(n+1)/2-1,numa=m/2+1;
for (int row=1;row<=targeta;row++)
{
for (int col=1;col<=m;col++)
{
if (col<=numa) a[row][col]='+';
else a[row][col]='-';
}
}
for (int row=targeta+1;row<=n;row++)
{
for (int col=1;col<=m;col++) a[row][col]='-';
}
}
else
{
int targetb=(m+1)/2-1,numb=n/2+1;
for (int col=1;col<=targetb;col++)
{
for (int row=1;row<=n;row++)
{
if (row<=numb) a[row][col]='-';
else a[row][col]='+';
}
}
for (int col=targetb+1;col<=m;col++)
{
for (int row=1;row<=n;row++) a[row][col]='+';
}
}
cout<<max(n,m)+(min(n,m)+1)/2-1<<endl;
for (int row=1;row<=n;row++)
{
for (int col=1;col<=m;col++) cout<<a[row][col];
cout<<endl;
}
continue;
}
int answer=n+m-3;if (min(n,m)%2==1) answer++;
cout<<answer<<endl;
if (n<=m)
{
int potrebno=(n+2)/2-2;int curn=n-2;
for (int row=1;row<=n;row++)
{
for (int col=1;col<=m;col++) a[row][col]='+';
}
for (int col=1;col<=m;col++) a[n-1][col]=a[n][col]='-';
if (n%2==0)
{
potrebno--;curn--;for (int col=1;col<=m;col++) a[n-2][col]='-';
}
int current=1;
for (int col=1;col<=m;col++)
{
int number=0;
while (number<potrebno)
{
a[current][col]='-';
if (current==curn) current=1;
else current++;
number++;
}
}
}
else
{
int potrebno=(m+2)/2;int curm=m-2;
for (int row=1;row<=n;row++)
{
for (int col=1;col<=m;col++) a[row][col]='-';
}
for (int row=1;row<=n;row++) a[row][m-1]=a[row][m]='+';
if (m%2==0)
{
potrebno--;curm--;for (int row=1;row<=n;row++) a[row][m-2]='+';
}
int current=1;
for (int row=1;row<=n;row++)
{
int number=0;
while (number<potrebno)
{
a[row][current]='+';
if (current==curm) current=1;
else current++;
number++;
}
}
}
for (int row=1;row<=n;row++)
{
for (int col=1;col<=m;col++) cout<<a[row][col];
cout<<endl;
}
}
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
