#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e18;
void solve(){
int n,m;cin>>n>>m;
int flag=(n>m);
if(flag)swap(n,m);
vector<vector<int>> v(n,vector<int>(m,1));
int need=(m+2)/2;
int p=(n-1)/2*m;
int ans=m+p/need;
queue<int> q;
for(int i=0;i<m;i++){
q.push(i);
}
for(int i=0;i<p/need;i++){
for(int j=0;j<need;j++){
int r=q.front();
q.pop();
v[i][r]=0;
q.push(r);
}
}
cout<<ans<<endl;
if(!flag){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<(v[i][j]?'-':'+');
}
cout<<endl;
}
}
else{
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<(v[j][i]?'+':'-');
}
cout<<endl;
}
}
}
int32_t main() {
LCBorz;
int t;cin>>t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1552 KB |
Output is correct |
2 |
Correct |
18 ms |
6492 KB |
Output is correct |
3 |
Correct |
17 ms |
6936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1736 KB |
Output is correct |
2 |
Correct |
17 ms |
4956 KB |
Output is correct |
3 |
Correct |
14 ms |
3492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
19 ms |
1552 KB |
Output is correct |
6 |
Correct |
18 ms |
6492 KB |
Output is correct |
7 |
Correct |
17 ms |
6936 KB |
Output is correct |
8 |
Correct |
21 ms |
1736 KB |
Output is correct |
9 |
Correct |
17 ms |
4956 KB |
Output is correct |
10 |
Correct |
14 ms |
3492 KB |
Output is correct |
11 |
Correct |
5 ms |
604 KB |
Output is correct |
12 |
Correct |
16 ms |
4456 KB |
Output is correct |
13 |
Correct |
16 ms |
3740 KB |
Output is correct |
14 |
Correct |
14 ms |
2648 KB |
Output is correct |
15 |
Correct |
27 ms |
9300 KB |
Output is correct |
16 |
Correct |
15 ms |
6744 KB |
Output is correct |
17 |
Correct |
7 ms |
3164 KB |
Output is correct |