#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const int MAXN = 1e3+10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int n, m;
/// 1 - red
/// 0 - blue
int a[MAXN][MAXN];
int cnt[MAXN];
void solve_test()
{
cin >> n >> m;
int nooo = 0;
if(n < m)
{
nooo = 1;
swap(n, m);
}
if(n >= m)
{
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
a[i][j] = 1;
}
memset(cnt, 0, sizeof(cnt));
int togive = (m - 1)/2;
int need = n/2 + 1;
int i = 1;
int ans = n;
for (int j = 1; j <= m; ++ j)
{
if(cnt[i] >= togive)break;
int token = need;
while(token)
{
if(cnt[i] >= togive)break;
a[i][j] = 0;
//cout << i << " " << j << " " << endl;
token --;
cnt[i] ++;
i ++;
if(i == n+1)i = 1;
}
if(!token)ans ++;
}
if(!nooo)
{
cout << ans << endl;
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
{
if(a[i][j] == 1)cout << '+';
else cout << '-';
}
cout << endl;
}
}
else
{
cout << ans << endl;
for (int i = 1; i <= m; ++ i)
{
for (int j = 1; j <= n; ++ j)
{
if(a[j][i] == 0)cout << '+';
else cout << '-';
}
cout << endl;
}
}
}
}
int main()
{
speed();
int t;
cin >> t;
while(t --)
{
solve_test();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
3676 KB |
Output is correct |
2 |
Correct |
17 ms |
4696 KB |
Output is correct |
3 |
Correct |
15 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
3676 KB |
Output is correct |
2 |
Correct |
18 ms |
3928 KB |
Output is correct |
3 |
Correct |
13 ms |
3420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
2 ms |
2652 KB |
Output is correct |
5 |
Correct |
18 ms |
3676 KB |
Output is correct |
6 |
Correct |
17 ms |
4696 KB |
Output is correct |
7 |
Correct |
15 ms |
4956 KB |
Output is correct |
8 |
Correct |
17 ms |
3676 KB |
Output is correct |
9 |
Correct |
18 ms |
3928 KB |
Output is correct |
10 |
Correct |
13 ms |
3420 KB |
Output is correct |
11 |
Correct |
5 ms |
600 KB |
Output is correct |
12 |
Correct |
14 ms |
4300 KB |
Output is correct |
13 |
Correct |
15 ms |
4696 KB |
Output is correct |
14 |
Correct |
11 ms |
3932 KB |
Output is correct |
15 |
Correct |
17 ms |
5212 KB |
Output is correct |
16 |
Correct |
14 ms |
4700 KB |
Output is correct |
17 |
Correct |
6 ms |
3420 KB |
Output is correct |