#include <bits/stdc++.h>
#include <math.h>
typedef long long ll;
using namespace std;
ll i, j, t, a, n, m, b, c, d, f, g;
char ch[1010][1010];
void quickSort(int *array, int low, int high)
{
int i=low;int j=high;int pivot=array[(i + j)/2];int temp;while(i<=j){while(array[i]<pivot)i++;while(array[j]>pivot)j--;
if(i<=j){temp=array[i];array[i]=array[j];array[j]=temp;i++;j--;}}if(j>low)quickSort(array,low,j);if(i<high)quickSort(array,i,high);
}
int binarySearch(int array[], int x, int low, int high)
{
while(low<=high){int mid=low+(high-low)/2;if(array[mid]==x)return mid;
if(array[mid]<x)low=mid+1;else high=mid-1;}return -1;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin>>t;
for (i=1; i<=t; i++)
{
cin>>n>>m;
if (n<m)
{
if (n==1 or n==2)
{
cout<<m<<endl;
for (a=1; a<=n; a++)
{
for (b=1; b<=m; b++) cout<<'-';
cout<<endl;
}
continue;
}
else
{
cout<<m+((n-3)/2)+1<<endl;
for (a=1; a<=2; a++)
{
for (b=1; b<=m; b++) cout<<'-';
cout<<endl;
}
for (a=1; a<=m; a++) cout<<'+';
cout<<endl;
for (a=4; a<=n; a++)
{
if (a%2==0) for (b=1; b<=m; b++) cout<<'-';
else for (b=1; b<=m; b++) cout<<'+';
cout<<endl;
}
continue;
}
}
else
{
if (m==1 or m==2)
{
cout<<n<<endl;
for (a=1; a<=n; a++)
{
for (b=1; b<=m; b++) cout<<'+';
}
cout<<endl;
continue;
}
else
{
cout<<n+((m-3)/2)+1<<endl;
for (a=1; a<=2; a++)
{
for (b=1; b<=n; b++) ch[b][a]='+';
}
for (a=1; a<=n; a++) ch[a][3]='-';
for (a=4; a<=m; a++)
{
if (a%2==0) for (b=1; b<=n; b++) ch[b][a]='+';
else for (b=1; b<=n; b++) ch[b][a]='-';
}
for (a=1; a<=n; a++)
{
for (b=1; b<=m; b++) cout<<ch[a][b];
cout<<endl;
}
}
}
}
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
320 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
320 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
1396 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
1372 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
320 KB |
Wrong answer |