이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
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... |