#include <bits/stdc++.h>
#define ll long long
#define i128 __int128_t
#define pii pair<int, int>
#define oo 1e9
using namespace std;
void solve(){
int n, m; cin >> n >> m;
bool flipped = false;
if(m < n){
flipped = true;
swap(n, m);
}
vector<vector<bool>> grid(n, vector<bool>(m, 0));
if(n <= 2){
cout << m << '\n';
}
else if(n <= 4){
cout << m + 1 << '\n';
for (int i = 0; i < m; i++)
{
grid[0][i] = 1;
}
}
else if(n <= 6){
cout << m + 3 << '\n';
for (int i = 0; i < m / 2 + m % 2; i++)
{
grid[0][i] = 1;
}
for (int i = m / 2 + m % 2 - 1; i < m; i++)
{
grid[1][i] = 1;
}
for (int i = 0; i < m; i++)
{
grid[2][i] = 1;
}
grid[2][m / 2 + m % 2 - 1] = 0;
}
if(!flipped){
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if(grid[i][j]) cout << '+';
else cout << '-';
}
cout << '\n';
}
}
else{
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if(!grid[j][i]) cout << '+';
else cout << '-';
}
cout << '\n';
}
}
}
int main()
{
int t; cin >> t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
2 ms |
284 KB |
Output is correct |
4 |
Incorrect |
3 ms |
340 KB |
in the table A+B is not equal to 41 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
1324 KB |
Expected integer, but "+++++++++++++++++++++" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
1228 KB |
Expected integer, but "------------------------" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
2 ms |
284 KB |
Output is correct |
4 |
Incorrect |
3 ms |
340 KB |
in the table A+B is not equal to 41 |
5 |
Halted |
0 ms |
0 KB |
- |