#include <iostream>
using namespace std;
void solve()
{
int n, m;
cin >> n >> m;
bool swapped = false;
if (n < m)
{
int t = n;
n = m, m = t, swapped = true;
}
char a[n][m];
for (int i=0; i<n; i++) for (int j=0; j<m; j++) a[i][j] = '+';
int ans = n, x = 0, c = 0;
for (int k=0; k<(m-1)/2; k++) for (int y=0; y<n; y++)
{
a[y][x] = '-', c++;
if (c == n/2+1) x++, c=0, ans++;
}
cout << ans << '\n';
if (!swapped) for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++) cout << a[i][j];
cout << '\n';
}
else for (int j=0; j<m; j++)
{
for (int i=0; i<n; i++) cout << (a[i][j]=='+'?'-':'+');
cout << '\n';
}
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while(t--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
312 KB |
Output is correct |
4 |
Correct |
2 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1220 KB |
Output is correct |
2 |
Correct |
19 ms |
1844 KB |
Output is correct |
3 |
Correct |
19 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
1292 KB |
Output is correct |
2 |
Correct |
24 ms |
1580 KB |
Output is correct |
3 |
Correct |
16 ms |
1328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
312 KB |
Output is correct |
4 |
Correct |
2 ms |
316 KB |
Output is correct |
5 |
Correct |
23 ms |
1220 KB |
Output is correct |
6 |
Correct |
19 ms |
1844 KB |
Output is correct |
7 |
Correct |
19 ms |
1868 KB |
Output is correct |
8 |
Correct |
21 ms |
1292 KB |
Output is correct |
9 |
Correct |
24 ms |
1580 KB |
Output is correct |
10 |
Correct |
16 ms |
1328 KB |
Output is correct |
11 |
Correct |
8 ms |
440 KB |
Output is correct |
12 |
Correct |
16 ms |
1468 KB |
Output is correct |
13 |
Correct |
17 ms |
1328 KB |
Output is correct |
14 |
Correct |
13 ms |
1008 KB |
Output is correct |
15 |
Correct |
21 ms |
2164 KB |
Output is correct |
16 |
Correct |
16 ms |
1740 KB |
Output is correct |
17 |
Correct |
8 ms |
844 KB |
Output is correct |