#include "bits/stdc++.h"
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int n, m;
cin >> n >> m;
char ans[n+5][m+5];
set<pair<int, int> > touse;
int res = 0;
if(n > m + (m/2) || (n - m >= -1 && n % 2))
{
for(int i = 1; i <= n; i++)
for(int a = 1; a <= m; a++)
ans[i][a] = '+';
res = n;
for(int i = 1; i <= n; i++)
touse.insert({0, i});
for(int i = 1; i <= m; i++)
{
int curr = 0;
bool valid = true;
while(curr <= n / 2)
{
pair<int, int> front = *(touse.begin());
if(front.first + 1 >= (m+1) / 2) {
valid = false;
break;
}
front.first++;
ans[front.second][i] = '-';
touse.erase(touse.begin());
touse.insert(front);
curr++;
//cout << curr << " " << front.first << " " << front.second << "\n";
}
if(!valid)
break;
res++;
}
} else
{
for(int i = 1; i <= n; i++)
for(int a = 1; a <= m; a++)
ans[i][a] = '-';
res = m;
for(int i = 1; i <= m; i++)
touse.insert({0, i});
for(int i = 1; i <= n; i++)
{
int curr = 0;
bool valid = true;
while(curr <= m / 2)
{
pair<int, int> front = *(touse.begin());
if(front.first + 1 >= (n+1) / 2) {
valid = false;
break;
}
front.first++;
ans[i][front.second] = '+';
touse.erase(touse.begin());
touse.insert(front);
curr++;
}
if(!valid)
break;
res++;
}
}
cout << res << "\n";
for(int i = 1; i <= n; i++) {
for(int a = 1; a <= m; a++) {
cout << ans[i][a];
}
cout << "\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Wrong answer in test 4 3: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Wrong answer in test 4 3: 4 < 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Wrong answer in test 4 3: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
1228 KB |
Output is correct |
2 |
Correct |
73 ms |
1872 KB |
Output is correct |
3 |
Correct |
75 ms |
1808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
1284 KB |
Output is correct |
2 |
Correct |
64 ms |
1580 KB |
Output is correct |
3 |
Correct |
61 ms |
1312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Wrong answer in test 4 3: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |