This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e18;
void solve(){
int n,m;cin>>n>>m;
int flag=(n>m);
if(flag)swap(n,m);
vector<vector<int>> v(n,vector<int>(m));
int ans=0;
if(n==1){
for(int i=0;i<m;i++){
v[0][i]=1;
}
ans=m;
}
else if(n==2){
ans=m;
for(int i=0;i<m;i++){
v[0][i]=1;
v[1][i]=1;
}
}
else if(n==3){
ans=m+1;
for(int i=0;i<m;i++){
v[0][i]=1;
v[1][i]=1;
}
}
else{
int need=(m+2)/2;
int p=(n-1)/2*m;
ans=m+p/need;
queue<int> q;
for(int i=0;i<m;i++){
q.push(i);
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
v[i][j]=1;
}
}
for(int i=0;i<p/need;i++){
for(int j=0;j<need;j++){
int r=q.front();
q.pop();
v[i][r]=0;
q.push(r);
}
}
}
cout<<ans<<endl;
if(!flag){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<(v[i][j]?'-':'+');
}
cout<<endl;
}
}
else{
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<(v[j][i]?'+':'-');
}
cout<<endl;
}
}
}
int32_t main() {
LCBorz;
int t;cin>>t;
while(t--){
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... |