#include <bits/stdc++.h>
using namespace std;
vector <vector <char>> a;
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n, m;
cin >> n >> m;
if(n >= m){
a.assign(n, vector <char> (m,'+'));
int x = 0;
for(int j = 0; j < (m+1)/2; j++){
int cnt = ((n+1)/2);
while(cnt--){
a[x][j] = '-';
x++;
x %= n;
}
}
}
else {
a.assign(n, vector <char> (m,'-'));
int x = 0;
for(int j = 0; j < (n)/2; j++){
int cnt = ((m+1)/2);
while(cnt--){
a[j][x] = '+';
x++;
x %= m;
}
}
}
int ans = 0;
for(int i = 0; i < n; i++){
int a1 = 0, b1 = 0;
for(int j = 0; j < m; j++){
if(a[i][j] == '+') a1++;
else b1++;
}
ans += (a1 > b1);
}
for(int j = 0; j < m; j++){
int a1 = 0, b1 = 0;
for(int i = 0; i < n; i++){
if(a[i][j] == '+') a1++;
else b1++;
}
ans += (b1 > a1);
}
cout << ans << '\n';
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << a[i][j];
}
cout << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer in test 2 1: 1 < 2 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Wrong answer in test 2 1: 1 < 2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer in test 2 1: 1 < 2 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
1300 KB |
Wrong answer in test 97 21: 108 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
1524 KB |
Wrong answer in test 24 24: 24 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer in test 2 1: 1 < 2 |
3 |
Halted |
0 ms |
0 KB |
- |