// quit the talkin', cut the check!
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define nptr nullptr
using namespace std;
const int MAXN = 2e4 + 1;
const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INFLL = 1e18;
const ld PI = acos(-1);
void solve() {
int n, m;
cin >> n >> m;
char a[n][m];
if(n > m){
for(int i = 0; i < m; ++i){
for(int j = 0; j < n; ++j){
if(i >= 1 + !(m & 1) && ((i - (1 + !(m & 1))) % 2 == 0 && j <= n / 2)){
a[j][i] = '-';
}
else a[j][i] = '+';
}
}
}
else{
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(i >= 1 + !(n & 1) && ((i - (1 + !(n & 1))) % 2 == 0 && j <= m / 2)){
a[i][j] = '+';
}
else a[i][j] = '-';
}
}
}
int ans = 0;
for(int i = 0; i < n; ++i){
int sum = 0;
for(int j = 0; j < m; ++j){
sum += bool(a[i][j] == '+');
}
ans += bool(sum > m / 2);
}
for(int j = 0; j < m; ++j){
int sum = 0;
for(int i = 0; i < n; ++i){
sum += bool(a[i][j] == '-');
}
ans += bool(sum > n / 2);
}
cout << ans << '\n';
for(int i = 0; i < n; ++i, cout << '\n'){
for(int j = 0; j < m; ++j){
cout << a[i][j];
}
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("brokeday.in","r",stdin);
//freopen("richday.out","w",stdout);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
2 ms |
364 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
1388 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
1388 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
2 ms |
364 KB |
Wrong answer in test 5 29: 31 < 32 |