#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
const int maxn = 1001;
int n,m;
char tab[maxn][maxn];
bool swapnati;
void read()
{
cin >> n >> m;
swapnati = false;
if(n<m)
{
swapnati = true;
swap(n,m);
}
int ans = n;
int minusi = (m-1)/2 * n;
int colonki = minusi / (n/2 + 1);
minusi = colonki * (n/2+1);
ans += colonki;
cout << ans << endl;
if(swapnati)
{
for(int j = 1; j <= colonki; j++)
{
for(int i = 1; i < j; i++) tab[j][i] = '-';
for(int i = j; i < j+(n/2+1); i++) tab[j][i] = '+';
for(int i = j+(n/2+1); i <= n; i++) tab[j][i] = '-';
}
for(int i = 1; i <= n; i++)
{
for(int j = colonki + 1; j <= m; j++) tab[j][i] = '-';
}
swap(n,m);
}
else
{
for(int j = 1; j <= colonki; j++)
{
for(int i = 1; i < j; i++) tab[i][j] = '+';
for(int i = j; i < j+(n/2+1); i++) tab[i][j] = '-';
for(int i = j+(n/2+1); i <= n; i++) tab[i][j] = '+';
}
for(int i = 1; i <= n; i++)
{
for(int j = colonki + 1; j <= m; j++) tab[i][j] = '+';
}
}
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++) cout << tab[i][j];
cout << endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--) read();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
in the table A+B is not equal to 32 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
1628 KB |
in the table A+B is not equal to 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
1624 KB |
in the table A+B is not equal to 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
in the table A+B is not equal to 32 |
5 |
Halted |
0 ms |
0 KB |
- |