#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;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
{
tab[i][j] = '#';
}
}
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)
{
int old = 1;
for(int j = 1; j <= colonki; j++)
{
for(int q = 1; q <= (n/2+1); q++)
{
tab[j][old] = '+';
old++;
if(old>n) old = 1;
}
for(int i = 1; i <= n; i++) if(tab[j][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
{
int old = 1;
for(int j = 1; j <= colonki; j++)
{
for(int q = 1; q <= (n/2+1); q++)
{
tab[old][j] = '-';
old++;
if(old>n) old = 1;
}
for(int i = 1; i <= n; i++) if(tab[i][j]=='#') 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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1372 KB |
Output is correct |
2 |
Correct |
17 ms |
1888 KB |
Output is correct |
3 |
Correct |
17 ms |
2140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
1372 KB |
Output is correct |
2 |
Correct |
16 ms |
1884 KB |
Output is correct |
3 |
Correct |
14 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
19 ms |
1372 KB |
Output is correct |
6 |
Correct |
17 ms |
1888 KB |
Output is correct |
7 |
Correct |
17 ms |
2140 KB |
Output is correct |
8 |
Correct |
17 ms |
1372 KB |
Output is correct |
9 |
Correct |
16 ms |
1884 KB |
Output is correct |
10 |
Correct |
14 ms |
1628 KB |
Output is correct |
11 |
Correct |
5 ms |
600 KB |
Output is correct |
12 |
Correct |
16 ms |
1884 KB |
Output is correct |
13 |
Correct |
15 ms |
2136 KB |
Output is correct |
14 |
Correct |
12 ms |
1632 KB |
Output is correct |
15 |
Correct |
19 ms |
2396 KB |
Output is correct |
16 |
Correct |
14 ms |
1884 KB |
Output is correct |
17 |
Correct |
6 ms |
1372 KB |
Output is correct |