#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define MAX 1000
lli n,m,t,mejor,lim,f,c,b,a,ini,todo;
pair<lli,lli> cant;
char res[MAX+2][MAX+2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
rep(i,1,t) {
cin >> n >> m;
mejor = 0;
f = n / 2;
f++;
c = m / 2;
c++;
lim = n*m;
repa(i,n,0) {
repa(j,m,0) {
a = i*c;
a += j*f;
a += (n-i)*(m-j);
b = i + j;
if (a > lim) continue;
if (b <= mejor) break;
mejor = b;
cant = {i,j};
}
}
rep(i,1,n) {
rep(j,1,m) res[i][j] = '-';
}
ini = 1;
c -= m - cant.second;
rep(i,1,cant.first) {
rep(j,1,c) {
res[i][ini] = '+';
ini++;
if (ini > cant.second) ini = 1;
}
rep(j,cant.second+1,m) res[i][j] = '+';
}
cout << mejor << "\n";
rep(i,1,n) {
rep(j,1,m) cout << res[i][j];
cout << "\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
1356 KB |
Output is correct |
2 |
Correct |
22 ms |
1836 KB |
Output is correct |
3 |
Correct |
19 ms |
2048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
1364 KB |
Output is correct |
2 |
Correct |
17 ms |
1780 KB |
Output is correct |
3 |
Correct |
17 ms |
1556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
35 ms |
1356 KB |
Output is correct |
6 |
Correct |
22 ms |
1836 KB |
Output is correct |
7 |
Correct |
19 ms |
2048 KB |
Output is correct |
8 |
Correct |
21 ms |
1364 KB |
Output is correct |
9 |
Correct |
17 ms |
1780 KB |
Output is correct |
10 |
Correct |
17 ms |
1556 KB |
Output is correct |
11 |
Correct |
6 ms |
596 KB |
Output is correct |
12 |
Correct |
17 ms |
1876 KB |
Output is correct |
13 |
Correct |
18 ms |
2036 KB |
Output is correct |
14 |
Correct |
14 ms |
1612 KB |
Output is correct |
15 |
Correct |
24 ms |
2252 KB |
Output is correct |
16 |
Correct |
15 ms |
1748 KB |
Output is correct |
17 |
Correct |
7 ms |
1236 KB |
Output is correct |