이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# 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( !q1 )break;
if( cnt[j] == mn ){
a[i][j] = '+';
cnt[j] ++;
cnt1--;
q1--;
if( !cnt1 ){
cnt1 = m;
mn++;
if( mn == (n-1)/2 ){
mn = -1;
break;
}
}
}
}
for( int j = 0; j < m; j ++ ){
if( !q1 )break;
if( cnt[j] == mn ){
a[i][j] = '+';
cnt[j] ++;
cnt1--;
q1--;
if( !cnt1 ){
cnt1 = m;
mn++;
if( mn == (n-1)/2 ){
mn = -1;
break;
}
}
}
}
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( !q1 )break;
if( cnt[i] == mn ){
a[i][j] = '-';
cnt[i]++;
cnt1--;
q1--;
if( !cnt1 ){
cnt1 = n;
mn++;
if( mn == (m-1)/2 ){
mn = -1;
break;
}
}
}
}
for( int i = 0; i < n; i ++ ){
if( !q1 )break;
if( cnt[i] == mn ){
a[i][j] = '-';
cnt[i]++;
cnt1--;
q1--;
if( !cnt1 ){
cnt1 = n;
mn++;
if( mn == (m-1)/2 ){
mn = -1;
break;
}
}
}
}
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... |