#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 < 3) {
vector<vector<char> > c(n, vector<char>(m, '-'));
cout << m << "\n";
print(c);
continue;
} else if(m < 3) {
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";
| ~~~~~^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 2 1: 1 < 2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Wrong answer in test 2 1: 1 < 2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 2 1: 1 < 2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
1348 KB |
Output is correct |
2 |
Correct |
23 ms |
1576 KB |
Output is correct |
3 |
Correct |
23 ms |
1880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
1244 KB |
Wrong answer in test 4 4: 4 < 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 2 1: 1 < 2 |