#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define sp << " " <<
#define endl << '\n'
/*
row -> +
col -> -
*/
long long int row, col;
void solve(){
cin >> row >> col;
bool rotated = row < col;
if (rotated){
swap(row, col);
}
cout << row + (row * ((col - 1) / 2)) / (row - (row - 1) / 2) endl;
vector<vector<bool>> table(row, vector<bool>(col, false));
set<pair<long long int, long long int>> cl;
for (int i = (row * ((col - 1) / 2)) / (row - (row - 1) / 2); i > 0; i--){
cl.insert({ 0, i - 1 });
}
vector<pair<long long int, long long int>> del;
for (int i = 0; i < row; i++){
for (int o = (col - 1) / 2; o > 0; o--){
table[i][cl.begin()->second] = true;
del.push_back({ cl.begin()->first + 1, cl.begin()->second });
cl.erase(cl.begin());
}
for (auto k : del){
cl.insert(k);
}
del.clear();
}
if (rotated)
swap(col, row);
for (int i = 0; i < row; i++){
for (int o = 0; o < col; o++){
if (rotated){
if (table[o][i]){
cout << "+";
}else{
cout << "-";
}
}else{
if (table[i][o]){
cout << "-";
}else{
cout << "+";
}
}
}
cout endl;
}
cout endl;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int Q;
cin >> Q;
while (Q--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |