#include <iostream>
#define NMAX 1000
using namespace std;
char a[NMAX+10][NMAX+10];
void solve(){
int n, m;
cin >> n >> m;
int badColumns = 0;
int ans = max(n, m), p = 0;
if(n > m)
p = n;
for(int i=1; i<=n; i++){
int cnt = (m / 2 + 1) * i;
if(cnt > (m - badColumns) * (n / 2) + badColumns * i){
if(badColumns == m)
break;
i--;
badColumns++;
continue;
}
if(i + (m - badColumns) > ans){
ans = i + (m - badColumns);
p = i;
}
}
badColumns = 0;
while(1){
int cnt = (m / 2 + 1) * p;
if(cnt > (m - badColumns) * (n / 2) + badColumns * p){
badColumns++;
continue;
}
for(int j=1; j<=m; j++)
for(int i=1; i<=n; i++){
if(j <= badColumns)
a[i][j] = '+';
else
a[i][j] = '-';
}
int j = badColumns + 1;
for(int i=1; i<=p; i++)
for(int nr=1; nr<=m/2+1-badColumns; nr++){
a[i][j] = '+';
j++;
if(j == m + 1)
j = badColumns + 1;
}
cout << ans << '\n';
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++)
cout << a[i][j] << ' ';
cout << '\n';
}
break;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
2408 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
2400 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |