#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = 1010;
vector<vector<char>> get(int n, int m, int &sol){
vector<vector<char>> sos;
sos.resize(n);
for(int i = 0 ; i < n; i ++ ){
for(int j = 0 ; j < m ; j ++ ){
sos[i].push_back('-');
}
}
for(int i = 0 ; i < n; i ++ ){
for(int j = 0; j < (m + 2) / 2; j ++ ){
sos[i][j] = '+';
}
}
int xx;
int take;
if(m % 2 == 1){
take = m/2 - 1;
}
else{
take = (m+2)/2 - 4;
}
for(int jj = 0 ; jj < take; jj ++ ){
xx = jj-1;
for(int id = 0; id < (n + 2) / 2; id ++ ){
xx ++ ;
xx %= (m - 1)/2;
sos[id][jj] = '-';
sos[id][xx+(m+2)/2] = '+';
}
}
sol = 0;
int cnt;
for(int i = 0 ; i < n; i ++ ){
cnt = 0;
for(int j = 0 ; j < m ; j ++ ){
if(sos[i][j] == '+'){
cnt ++ ;
}
}
if(cnt >= (m + 2) / 2){
sol ++ ;
}
}
for(int j = 0 ; j < m ; j ++ ){
cnt = 0;
for(int i = 0 ; i < n; i ++ ){
if(sos[i][j] == '-'){
cnt ++ ;
}
}
if(cnt >= (n + 2) / 2){
sol ++ ;
}
}
return sos;
}
void solve(){
int n, m;
cin >> n >> m;
int res1 = 0;
int res2 = 0;
vector<vector<char>> s1 = get(n, m, res1);
vector<vector<char>> s2 = get(m, n, res2);
if(res1 >= res2){
cout << res1 << "\n";
for(auto x : s1){
for(auto y : x){
cout << y;
}
cout << "\n";
}
}
else{
cout << res2 << "\n";
for(int i = 0 ; i < n; i ++ ){
for(int j = 0 ; j < m ; j ++ ){
if(s2[j][i] == '-'){
s2[j][i] = '+';
}
else{
s2[j][i] = '-';
}
cout << s2[j][i];
}
cout << "\n";
}
}
}
int main(){
fastIO;
//freopen("in.txt","r",stdin);
int tc;
cin >> tc;
for(int iq = 1; iq <= tc; iq ++ ){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
1280 KB |
Output is correct |
2 |
Correct |
58 ms |
2628 KB |
Output is correct |
3 |
Correct |
52 ms |
2904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
1368 KB |
Wrong answer in test 6 6: 8 < 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
332 KB |
Output is correct |
5 |
Correct |
67 ms |
1280 KB |
Output is correct |
6 |
Correct |
58 ms |
2628 KB |
Output is correct |
7 |
Correct |
52 ms |
2904 KB |
Output is correct |
8 |
Incorrect |
61 ms |
1368 KB |
Wrong answer in test 6 6: 8 < 9 |
9 |
Halted |
0 ms |
0 KB |
- |