#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn=1e3+5;
int tt;
int n,m,ans,b,a;
char c[maxn][maxn];
priority_queue<pair<int,int>>q;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> tt;
while(tt--){
cin >> n >> m;
if(min(n,m) <= 2){
if(n >= m) for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) c[i][j] = '+';
else for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) c[i][j] = '-';
cout<<max(n,m)<<'\n';
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++) cout<<c[i][j];
cout<<'\n';
}
continue;
}
for(int i = 1;i <= n;i++)
for(int j = 1;j <= m;j++) c[i][j] = '+';
b = (m-1)/2;
a = n/2+1;
ans = n + ((n*b)/a);
// cout<<a<<'\n';
while(!q.empty()) q.pop();
for(int i = 1;i <= n;i++) q.push({b,i});
for(int i = 1;i <= m;i++){
for(int j = 1;j <= a;j++){
if(q.empty()) break;
pair<int,int>x=q.top(); q.pop();
c[x.second][i] = '-';
if(x.first > 1) q.push({x.first-1,x.second});
}
}
cout<<ans<<'\n';
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
cout<<c[i][j];
}
cout<<'\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
512 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
69 ms |
1764 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
1644 KB |
Output is correct |
2 |
Correct |
65 ms |
1828 KB |
Output is correct |
3 |
Correct |
50 ms |
1772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer |