#include <bits/stdc++.h>
using namespace std;
int n, m; bool flip, ans[1005][1005];
void solve(){
cin >> n >> m; flip = (n > m);
if (flip) swap(n, m);
int H = n / 2 + 1, L = m / 2 + 1;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
ans[i][j] = 0;
for (int i = 1; i < n - H + 1; i++)
for (int j = 1; j <= L; j++)
ans[i][j] = 1;
int lose = (m % 2 == 0) + 1, gain = n - H;
if (gain - lose > 0)
for (int i = H + 1; i <= n; i++)
for (int j = m - L + 1; j <= m; j++)
ans[i][j] = 1;
cout<<m + (n - H) + max(gain - lose, 0)<<endl;
if (flip)
for (int j = 1; j <= m; j++)
for (int i = n; i; i--)
cout<<(ans[i][j] ? '-' : '+')<<(i == 1 ? "\n" : "");
else
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cout<<(ans[i][j] ? '+' : '-')<<(j == m ? "\n" : "");
}
int main(){
int tc; cin >> tc;
while (tc--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Incorrect |
4 ms |
332 KB |
Wrong answer in test 38 5: 40 < 41 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
1336 KB |
Output is correct |
2 |
Correct |
36 ms |
1860 KB |
Output is correct |
3 |
Correct |
34 ms |
1860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
1424 KB |
Wrong answer in test 6 6: 8 < 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Incorrect |
4 ms |
332 KB |
Wrong answer in test 38 5: 40 < 41 |