# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# define int long long
# define fi first
# define se second
using namespace std;
const int N = 1e3 + 7;
const int mod = 1e9 + 7;
char a[N][N];
int cnt[N];
void solve() {
int n, m, inv = 0;
cin >> n >> m;
if ( m > n ) {
inv = 1;
swap( n, m );
}
int needr = (m + 2) / 2;
for ( int i = 1; i <= n; i++ ) {
for ( int j = 1; j <= m; j++ ) {
if ( j <= needr ) {
if ( !inv ) {
a[i][j] = '+';
}
else {
a[i][j] = '-';
}
}
else {
if ( !inv ) {
a[i][j] = '-';
}
else {
a[i][j] = '+';
}
}
}
}
vector < int > vc(3);
vc[0] = n / 3 + ((n % 3) >= 1);
vc[1] = vc[0] + n / 3 + ((n % 3) == 2);
vc[2] = n;
int ans = n + (m - needr);
if ( m & 1 ) {
int cnt = (m - needr) / 2, ind = 0;
ans += cnt;
for ( int i = 1; i <= n; i++ ) {
if ( i <= vc[0] ) {
ind = 0;
}
else if ( i <= vc[1] ) {
ind = 1;
}
else {
ind = 2;
}
for ( int j = needr; j > needr - cnt; j-- ) {
if ( !inv ) {
a[i][j] = '-';
a[i][j + ind * cnt] = '+';
}
else {
a[i][j] = '+';
a[i][j + ind * cnt] = '-';
}
}
}
}
cout << ans << '\n';
if ( !inv ) {
for ( int i = 1; i <= n; i++ ) {
for ( int j = 1; j <= m; j++ ) {
cout << a[i][j];
}
cout << '\n';
}
}
else {
for ( int i = 1; i <= m; i++ ) {
for ( int j = 1; j <= n; j++ ) {
cout << a[j][i];
}
cout << '\n';
}
}
}
int32_t main() {
speed;
int T = 1;
cin >> T;
while ( T-- ) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
1516 KB |
Wrong answer in test 97 21: 112 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
1620 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Incorrect |
34 ms |
1516 KB |
Wrong answer in test 97 21: 112 < 116 |
6 |
Halted |
0 ms |
0 KB |
- |