#include <bits/stdc++.h>
using namespace std;
int calc(vector<string> &v, int n, int m){
int cnt = 0;
for(int i = 0; i < n; i++){
int a = 0, b= 0 ;
for(int j = 0; j < m; j++){
if(v[i][j] == '+') a++;
else b++;
}
cnt += (a > b);
}
for(int j = 0; j < m; j++){
int a = 0, b = 0;
for(int i = 0; i < n; i++){
if(v[i][j] == '-') a++;
else b++;
}
cnt += (a > b);
}
return cnt;
}
void printVec(vector<string> &v, int n, int m){
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << v[i][j];
}
cout << endl;
}
}
vector<string> rev(vector<string> v, int n, int m){
vector<string> a(m);
for(int i = 0; i < n; ++i){
for(int j = m - 1; j >= 0; --j){
if(v[i][j] == '+') a[m - j - 1].push_back('-');
else a[m - j - 1].push_back('+');
}
}
return a;
}
void solve(){
int n, m; cin >> n >> m;
bool r = 0;
if(n > m){
swap(n, m);
r = 1;
}
vector<string> v(n);
string s(m, '-');
v[0] = s;
string a(m / 2 + 1, '+'), b(m - (m / 2 + 1), '-');
for(int i = 1; i < n; i++){
if(i % 2) v[i] = a + b;
else v[i] = b + a;
}
if(r){
v = rev(v, n, m);
swap(n, m);
}
cout << calc(v, n, m) << endl;
// if(!r) printVec(v, n, m);
printVec(v, n, m);
}
int main(){
int t; cin >> t; while(t--)
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 2 4: 2 < 4 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
340 KB |
Wrong answer in test 20 2: 10 < 20 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 2 4: 2 < 4 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
1364 KB |
Output is correct |
2 |
Correct |
31 ms |
1960 KB |
Output is correct |
3 |
Correct |
38 ms |
3536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
50 ms |
1232 KB |
Wrong answer in test 24 24: 34 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 2 4: 2 < 4 |
3 |
Halted |
0 ms |
0 KB |
- |