#pragma GCC optimize ("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <chrono>
#include <thread>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i,a,b) for(int i = a;i <= b ;i++)
#define rev(i,a,b) for(int i =a ;i<= b ; i--)
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define pss pair<string,string>
#define pii pair<int,int>
#define vi vector <int>
#define ull unsigned ll
#define pll pair<ll,ll>
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define ll long long
#define pb push_back
#define pbb pop_back
#define endl '\n'
#define S second
#define F first
// #define int ll
const int modinput = 1000003;
const int mod = 1000000007;
const int modq = 998244353;
const int inf = 0x3F3F3F3F;
const int sz = 1e5+5;
const ll iinf = 1e18;
const int N = 200005;
const int MAX = 202;
const int sz1 = 505;
const ld eps = 1e-9;
vector<vector<pair<int,int>>>g;
std::vector<int>dist;
std::vector<int>path;
std::deque<int> q;
std::vector<int> w;
unordered_map<ll, int> mp;
void solve()
{
int n,m;
cin>>n>>m;
int n1 = n,m1 = m;
if(m < n){
swap(n,m);
}
if(n == 1 || n == 2) {
cout<<m;
cout<<endl;
if(n1 == n && m1 == m){
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout<<'-';
}
cout<<endl;
}
}
else{
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout<<'-';
}
cout<<endl;
}
}
}
else if(n == 3 || n == 4){
cout<<m + 1;
cout<<endl;
if(n1 == n && m1 == m){
for (int i = 0; i < n; i++) {
if(i != 2){
for (int j = 0; j < m; j++) {
cout<<'-';
}
}
else{
for (int j = 0; j < m; j++) {
cout<<'+';
}
}
cout<<endl;
}
}
else{
for (int i = 0; i < m; i++) {
if(i != 2){
for (int j = 0; j < n; j++) {
cout<<'-';
}
}
else{
for (int j = 0; j < n; j++) {
cout<<'+';
}
}
cout<<endl;
}
}
}
else{
cout<<m + 2;
cout<<endl;
if(n1 == n && m1 == m){
for (int i = 0; i < n; i++) {
if(i < 3){
for (int j = 0; j < m; j++) {
cout<<'-';
}
}
else{
for (int j = 0; j < m; j++) {
cout<<'+';
}
}
cout<<endl;
}
}
else{
for (int i = 0; i < m; i++) {
if(i < 3){
for (int j = 0; j < n; j++) {
cout<<'-';
}
}
else{
for (int j = 0; j < n; j++) {
cout<<'+';
}
}
cout<<endl;
}
}
}
///cout<<endl;
}//1 2 2 4 7 7
signed main() {
speed
int T = 1,X_X = 0;
cin>>T;
for (int cs = 1; cs <= T; cs++) {
//cout << "Case " << cs << ": ";
solve();
}
//ll n, l, r;
//while ( cin >> n >> l >> r /* and (n || m) */){
// cin >> m;
// solve(n, l, r);
//}
return 0;
}//429
# | 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... |