#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define N 1200005
#define MOD 1000000007
#define INF 0x3f3f3f3f
int res, cur;
int t[1005][1005];
int cnt[1005];
void go(){
int n, m;
cin>>n>>m;
bool sw = 0;
if(n < m){
sw = 1;
swap(n, m);
}
int cur = n;
for(int i = 1; i <= n; i++){
cnt[i] = m;
for(int j = 1; j <= m; j++){
t[i][j] = 1;
}
}
int q = (n + 2) >> 1;
for(int j = 1; j <= m; j++){
bool ok = 0;
for(int i = 0; i < q; i++){
t[(i + (j - 1) * q) % n + 1][j] = 0;
cnt[(i + (j - 1) * q) % n + 1]--;
if(cnt[(i + (j - 1) * q) % n + 1] <= m / 2){
ok = 1;
}
}
if(ok){
for(int i = 0; i < q; i++){
t[(i + (j - 1) * q) % n + 1][j] = 1;
}
break;
}
cur++;
}
cout<<cur<<'\n';
if(sw == 0){
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cout<<(t[i][j] == 1 ? '+' : '-');
}
cout<<'\n';
}
} else {
for(int j = 1; j <= m; j++){
for(int i = 1; i <= n; i++){
cout<<(t[i][j] == 1 ? '-' : '+');
}
cout<<'\n';
}
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int t;
cin>>t;
while(t--){
go();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
504 KB |
Output is correct |
4 |
Correct |
4 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
1784 KB |
Output is correct |
2 |
Correct |
45 ms |
4700 KB |
Output is correct |
3 |
Correct |
39 ms |
4856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
1860 KB |
Output is correct |
2 |
Correct |
57 ms |
4224 KB |
Output is correct |
3 |
Correct |
31 ms |
3320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
504 KB |
Output is correct |
4 |
Correct |
4 ms |
632 KB |
Output is correct |
5 |
Correct |
36 ms |
1784 KB |
Output is correct |
6 |
Correct |
45 ms |
4700 KB |
Output is correct |
7 |
Correct |
39 ms |
4856 KB |
Output is correct |
8 |
Correct |
33 ms |
1860 KB |
Output is correct |
9 |
Correct |
57 ms |
4224 KB |
Output is correct |
10 |
Correct |
31 ms |
3320 KB |
Output is correct |
11 |
Correct |
11 ms |
632 KB |
Output is correct |
12 |
Correct |
37 ms |
4216 KB |
Output is correct |
13 |
Correct |
35 ms |
4728 KB |
Output is correct |
14 |
Correct |
28 ms |
3960 KB |
Output is correct |
15 |
Correct |
44 ms |
5368 KB |
Output is correct |
16 |
Correct |
33 ms |
4728 KB |
Output is correct |
17 |
Correct |
15 ms |
3320 KB |
Output is correct |