#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
void print(vector<vector<char> > &c) {
for(int i = 0; i < sz(c); ++i) {
for(int j = 0; j < sz(c[0]); ++j) {
cout << c[i][j];
}
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
for(int ti = 1; ti <= t; ++ti) {
int n, m;
cin >> n >> m;
if(n == 1) {
vector<vector<char> > c(n, vector<char>(m, '-'));
cout << m << "\n";
print(c);
continue;
} else if(m == 1) {
vector<vector<char> > c(n, vector<char>(m, '+'));
cout << n << "\n";
print(c);
continue;
}
int x[2] = {n / 2 + 1, (n + 1) / 2 - 1};
int y[2] = {m / 2 + 1, (m + 1) / 2 - 1};
vector<vector<char> > c(n, vector<char>(m, '+'));
for(int i = 0; i < x[0]; ++i) {
for(int j = 0; j < y[1]; ++j) {
c[i][j] = '-';
}
}
for(int i = 0; i < x[1]; ++i) {
for(int j = y[1]; j < m; ++j) {
c[i][j] = '+';
}
}
for(int i = x[0]; i < n; ++i) {
for(int j = 0; j < y[0]; ++j) {
c[i][j] = '+';
}
}
for(int i = x[1]; i < n; ++i) {
for(int j = y[0]; j < m; ++j) {
c[i][j] = '-';
}
}
cout << (x[1] + y[1] << 1) << "\n";
print(c);
}
return 0;
}
Compilation message
stones.cpp: In function 'int main()':
stones.cpp:60:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
60 | cout << (x[1] + y[1] << 1) << "\n";
| ~~~~~^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 2 4: 2 < 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
in the table A+B is not equal to 18 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 2 4: 2 < 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1348 KB |
Output is correct |
2 |
Correct |
22 ms |
1604 KB |
Output is correct |
3 |
Correct |
31 ms |
1896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
1248 KB |
in the table A+B is not equal to 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 2 4: 2 < 4 |