#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3 + 66;
vector<vector<char>> r;
void solve() {
int n, m;
cin >> n >> m;
int ans = 0, ai = 0;
for (int A = 0 ; A <= n ; ++ A) {
int Acnt = ((m - 1) / 2) * A; // not A * (m-1) / 2!!!!!!!!!!!!!!!!
int Bcnt = (A * 2 - n + 1);
int B = (Bcnt >= 1 ? Acnt / Bcnt : m);
if (A + B >= ans) {
ans = A + B;
ai = A;
}
}
cout << ans << "\n";
r = vector<vector<char>>(n, vector<char>(m, '-'));
for (int i = 0 ; i < ai ; ++ i) {
r[i] = vector<char>(m, '+');
}
for (int i = 0, j = 0 ; i < m ; ++ i) {
int cnt = (ai * 2 - n + 1);
while (cnt-- > 0) {
r[j][i] = '-';
j++;
if (j == ai) j = 0;
}
}
for (auto &vec : r) {
for (char &i : vec) cout << i;
cout << "\n";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int tt;
cin >> tt;
while (tt--) {
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
364 KB |
in the table A+B is not equal to 2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
1388 KB |
in the table A+B is not equal to 294 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
1420 KB |
in the table A+B is not equal to 144 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 2 |