#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<set>
#include<string>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int gcd(int a, int b)
{
if (b == 0) return a;
return gcd(b, a % b);
}
ll binpow(ll a, ll b)
{
if (b == 0) return 1;
ll res = binpow(a, b / 2);
if (b % 2) return res * res * a;
return res * res;
}
bool isprime(int n) {
if (n == 1 || n == 0) return 0;
for (int i = 2; i * i <= n; i++) if (!(n % i)) return 0;
return 1;
}
void solve() {
int n, m; cin >> n >> m;
int mn = m + n;
//if (n == m && n % 2) {
// cout << mn - 2 << endl;
//}
//else if (n == m && !(n % 2)) {
// cout << mn - 4 << endl;
//}
if (m <= 2 && m < n) {
cout << n << endl;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << '+';
}
cout << endl;
}
return;
}
if (n <= 2) {
cout << m << endl;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << '-';
}
cout << endl;
}
return;
}
if ((n % 2) != (m % 2)) cout << mn - 3 << endl;
else {
if (n % 2) cout << mn - 2 << endl;
else cout << mn - 4 << endl;
}
vector<vector<char>> v(n * m);
//if (m >= n) {
for (int j = 0; j < m; j++) v[0].push_back('-');
for (int i = 1; i < n; i++) {
for (int j = 0; j < m; j++) {
if ((i % 2)){
if (j < (m / 2 + 1)) {
v[i].push_back('+');
}
else v[i].push_back('-');
}
else {
if (j >= (m - m / 2 - 1)) {
v[i].push_back('+');
}
else v[i].push_back('-');
}
}
}
if (!(n % 2)) {
for (int j = 0; j < m; j++) v[n - 1][j] = '-';
}
//}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << v[i][j];
}
cout << endl;
}
//
// ++
// ++
//
// ------
// ------
//
// ++
// ++
// ++
// ++
// ++
// ++
//
// ++-+-+
// +----+
// +-+-++
//
// ++-+-
// +----
// +-+-+
//
// ---
// ++-
// -++
// ++-
// -++
//
//
//
// -----
// -----
// --+++
// +++--
//
// -------
// ++++---
// ---++++
// ++++---
// ---++++
// -------
//
// --------
// +++++---
// ---+++++
// +++++---
// ---+++++
// +++++---
// ---+++++
//
//
//
//
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int t; cin >> t; while(t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 4 4: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
340 KB |
Wrong answer in test 4 3: 4 < 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 4 4: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
1480 KB |
Output is correct |
2 |
Correct |
34 ms |
17304 KB |
Output is correct |
3 |
Correct |
42 ms |
19088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
1808 KB |
Wrong answer in test 4 4: 4 < 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 4 4: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |