#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn=1e3+5;
int tt,ans,ps,need;
int n,m,tr,a[maxn][maxn];
int cnt[maxn],num[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> tt;
while(tt--){
cin >> n >> m;
tr = 0;
if(n % 2 == 0) swap(n,m),tr=1;
for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) a[i][j]=1;
if(min(n,m) <= 2){
ans = max(n,m);
for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++){
if(n > m) a[i][j]=1;
else a[i][j]=0;
}
}
else{
ans = n - 2,ps = m/2+1,need = n/2+1;
for(int i = n - 1;i <= n;i++) for(int j = 1;j <= m;j++) a[i][j]=0;
for(int i = 1;i <= m;i++) cnt[i] = 2;
for(int i = 1;i <= n-2;i++) num[i] = m;
for(int i = 1;i <= m;i++){
for(int j = 1;j <= n-2;j++){
if(cnt[i]==need){break;}
if(num[j] > ps){
a[j][i] = 0;
num[j]--,cnt[i]++;
}
}
if(cnt[i]==need) ans++;
}
}
cout<<ans<<'\n';
if(tr) swap(n,m);
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
char nw = '+';
if((tr and a[j][i]==1) or (tr==0 and a[i][j]==0)) nw = '-';
cout<<nw;
}
cout<<'\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 4 4: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
620 KB |
Wrong answer in test 27 3: 27 < 28 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 4 4: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
1772 KB |
Wrong answer in test 97 21: 115 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
1904 KB |
Wrong answer in test 19 19: 35 < 36 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 4 4: 4 < 5 |