This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//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;
unsigned int a[1001][1001], ans;
void f(unsigned int n,unsigned int m){
vector<pair<int,int>> v;
unsigned 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--;
}
}
}
}
unsigned int t;
int main(){
cin>>t;
while(t--){
unsigned 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";
}
}
}
}
/*
_________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 (stderr)
stones.cpp: In function 'void f(unsigned int, unsigned int)':
stones.cpp:38:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<=k;i++)
~^~~
stones.cpp:39:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=1;j<=m;j++) a[i][j] = 0;
~^~~
stones.cpp:42:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<=k;i++) v.push_back( {0,i} );
~^~~
stones.cpp:44:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<=m;i++){
~^~~
stones.cpp:51:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v.size();j++){
~^~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:91:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=1;j<=m;j++) if( a[j][i] == 1 ) cout<<"-";
~^~~
stones.cpp:101:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<=n;i++){
~^~~
stones.cpp:103:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=1;j<=m;j++) if(a[i][j] == 1) cout<<"+";
~^~~
stones.cpp:119:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<=n;i++){
~^~~
stones.cpp:121:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=1;j<=m;j++) if(a[i][j] == 1) cout<<"+";
~^~~
# | 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... |