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>
# define FILE
using namespace std;
int main(){
# ifdef FILEs
freopen( "input.txt", "r", stdin );
freopen( "output.txt", "w", stdout );
# endif
ios_base::sync_with_stdio( false );
int t;
cin >> t;
while( t -- ){
int n, m;
cin >> n >> m;
char a[n][m];
int ans = 0;
if( n < m ){
ans = m ;
for( int i = 0; i < n; i ++ ){
for( int j = 0; j < m; j ++ ){
a[i][j] = '-';
}
}
int cnt[m] = {}, mn = 0, cnt1 = m;
for( int i = 0; i < n; i ++ ){
int q1 = m/2+1;
for( int j = 0; j < m; j ++ ){
if( mn == (n-1)/2 ){
mn = -1;
break;
}
if( !q1 )break;
if( cnt[j] == mn ){
a[i][j] = '+';
cnt[j] ++;
cnt1--;
q1--;
if( !cnt1 ){
cnt1 = m;
mn++;
}
}
}
for( int j = 0; j < m; j ++ ){
if( mn == (n-1)/2 ){
mn = -1;
break;
}
if( !q1 )break;
if( cnt[j] == mn ){
a[i][j] = '+';
cnt[j] ++;
cnt1--;
q1--;
if( !cnt1 ){
cnt1 = m;
mn++;
}
}
}
if( q1 == 0 )
ans ++;
if( mn == -1 )
break;
}
}
else{
ans = n ;
for( int i = 0; i < n; i++ ){
for( int j = 0; j < m; j ++ ){
a[i][j] = '+';
}
}
int cnt[n] = {}, mn = 0, cnt1 = n;
for( int j = 0; j < m; j ++ ){
int q1 = n/2+1;
for( int i = 0; i < n; i ++ ){
if( mn == (m-1)/2 ){
mn = -1;
break;
}
if( !q1 )break;
if( cnt[i] == mn ){
a[i][j] = '-';
cnt[i]++;
cnt1--;
q1--;
if( !cnt1 ){
cnt1 = n;
mn++;
}
}
}
for( int i = 0; i < n; i ++ ){
if( mn == (m-1)/2 ){
mn = -1;
break;
}
if( !q1 )break;
if( cnt[i] == mn ){
a[i][j] = '-';
cnt[i]++;
cnt1--;
q1--;
if( !cnt1 ){
cnt1 = n;
mn++;
}
}
}
if( q1 == 0 )
ans ++;
if( mn == -1 )
break;
}
}
cout << ans << endl;
for( int i = 0; i < n; i ++ ){
for( int j = 0; j < m; j ++ ){
cout << a[i][j];
}cout << endl;
}
}
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... |