#include<bits/stdc++.h>
using namespace std;
void solve(){
int n,m;
cin>>n>>m;
vector<string>a;
if(n>=m){
a.assign(n,string(m,'+'));
vector<int>b(n,0);
for(int i=0;i<m;i++){
set<pair<int,int>>s;
for(int j=0;j<n;j++) s.insert({b[j],j});
for(int j=0;j<n/2+1;j++){
auto x=*s.begin();
s.erase(s.begin());
if(x.first>=(m-1)/2) break;
b[x.second]++;
a[x.second][i]='-';
}
}
}
else{
a.assign(n,string(m,'-'));
vector<int>b(m,0);
for(int i=0;i<n;i++){
set<pair<int,int>>s;
for(int j=0;j<m;j++) s.insert({b[j],j});
for(int j=0;j<m/2+1;j++){
auto x=*s.begin();
s.erase(s.begin());
if(x.first>=(n-1)/2) break;
b[x.second]++;
a[i][x.second]='+';
}
}
}
cout<<max(n,m)+(min(n,m)-1)/2<<'\n';
for(int i=0;i<n;i++){
cout<<a[i]<<'\n';
}
}
signed main(){
int t=1;
cin>>t;
while(t--){
solve();
cout<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Incorrect |
3 ms |
348 KB |
in the table A+B is not equal to 31 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
1360 KB |
in the table A+B is not equal to 107 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
1364 KB |
in the table A+B is not equal to 35 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Incorrect |
3 ms |
348 KB |
in the table A+B is not equal to 31 |
5 |
Halted |
0 ms |
0 KB |
- |