//Euzubillahimines-seytanir-rajim Bismillahir-rahmanir-rahym
/*
ID:
TASK:
LANG: C++
*/
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define PII pair<int,int>
#define inf 1000000001
using namespace std;
int a[1001][1001], ans;
void f(int n,int m){
vector<pair<int,int>> v;
int k = n*m - ( m*(n/2+1) );
k /= (m/2+1);
ans = m + k;
for(int i=1;i<=k;i++)
for(int j=1;j<=m;j++) a[i][j] = 0;
for(int i=1;i<=k;i++) v.push_back( {0,i} );
for(int i=1;i<=m;i++){
int l = k/2 + 1;
int t = m/2 + 1;
sort(v.begin(),v.end());
for(int j=0;j<v.size();j++){
if( l == 0) break;
if( v[j].ff < t ){
a[v[j].ss][i] = 1;
v[j].ff++;
l--;
}
}
}
}
int t;
int main(){
cin>>t;
while(t--){
int n, m;
cin>>n>>m;
if( n!= m ){
f( min(n,m) , max(n,m) );
cout<<ans<<"\n";
if( n > m ){
for(int i=n;i>=1;i--){
for(int j=1;j<=m;j++) if( a[j][i] == 1 ) cout<<"-";
else cout<<"+";
cout<<"\n";
}
}
else{
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++) if(a[i][j] == 1) cout<<"+";
else cout<<"-";
cout<<"\n";
}
}
}
else{
f(n,m);
cout<<ans<<"\n";
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++) if(a[i][j] == 1) cout<<"-";
else cout<<"+";
cout<<"\n";
}
}
cout<<"\n";
}
}
/*
_________oBBBBB8o oBBBBBBB8
_____o8BBBBBBBBBBB BBBBBBBBB8 o88o
___o8BBBBBB**8BBBB BBBBBBBBBB oBBBBBBBo
__oBBBBBBB* *** BBBBBBBBBB BBBBBBBBBBo
_8BBBBBBBBBBooooo *BBBBBBB8 *BB* 8BBBBBBo
_8BBBBBBBBBBBBBBBB8ooBBBBBBB8 8BBBBBBB8
__*BBBBBBBBBBBBBBBBBBBBBBBBBB8 o88BB88BBBBBBBBBBBB
____*BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB8
______**8BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB*
___________*BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB8*
____________*BBBBBBBBBBBBBBBBBBBBBBBB8888**
_____________BBBBBBBBBBBBBBBBBBBBBBB*
_____________*BBBBBBBBBBBBBBBBBBBBB*
______________*BBBBBBBBBBBBBBBBBB8
_______________*BBBBBBBBBBBBBBBB*
________________8BBBBBBBBBBBBBBB8
_________________8BBBBBBBBBBBBBBBo
__________________BBBBBBBBBBBBBBB8
__________________BBBBBBBBBBBBBBBB
__________________8BBBBBBBBBBBBBBB8
__________________*BBBBBBBBBBBBBBBB
__________________8BBBBBBBBBBBBBBBB8
_________________oBBBBBBBBBBBBBBBBBB
________________oBBBBBBBBBBBBBBBBBBB
________________BBBBBBBBBBBBBBBBBBBB
_______________8BBBBBBBBBBBBBBBBBBB8
______________oBBBBBBBBB88BBBBBBBBB8
______________8BBBBBBBBB*8BBBBBBBBB*
______________BBBBBBBBB* BBBBBBBBB8
______________BBBBBBBB8 oBBBBBBBBB*
______________8BBBBBBB oBBBBBBBB*
______________BBBBBBB* 8BBBBBBB*
_____________8BBBBBB* BBBBBBB*
____________8BBBBBB8 oBBBBBB8
___________8BBBBBB8 8BBBBBB*
__________oBBBBBB8 BBBBBBB8
__________BBBBBBB8 BBBBBBBB*
_________oBBBBBBB8 BBBBBBBB
_________8BBBBBB8 BBBBBBB*
_________BBBBBB* 8BBBBB*
________oBBBB8 BBBBB*
________oBBB8 BBBB*
________BBBB8 8BBBBo
_______8BBBB* oBBBBBBo
______8BBBB* *BBBBBBBB8o
______BBBBB* *88BBBo
*/
Compilation message
stones.cpp: In function 'void f(int, int)':
stones.cpp:51:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v.size();j++){
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
in the table A+B is not equal to 2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
61 ms |
1680 KB |
in the table A+B is not equal to 10 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
58 ms |
1860 KB |
in the table A+B is not equal to 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |