#include<bits/stdc++.h>
#define loop(n) for(int i=0; i<n; i++)
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define p_b push_back
#define l_b lower_bound
#define u_b upper_bound
#define m_p make_pair
#define m_t make_tuple
#define ar array
using namespace std;
const int M=1e9, mxN=1e5;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
//cout.tie(NULL);
int T;
cin>>T;
while(T--){
int n, m, ans=0;
cin>>n>>m;
char a[n][m];
if(n<=m){
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[i][j]='-';
}
}
int x=m/2+1, y=n/2-(n%2==0);
// cout<<x<<' '<<y<<endl;
for(int i=0; i<y; i++){
for(int j=0; j<x; j++){
a[i][j]='+';
}
}
ans=m+y;
// cout<<x<<' '<<abs(n-(y*2))<<endl;
if(y>abs(m-(x*2))){
for(int i=y; i<y+y; i++){
for(int j=x-abs(m-(x*2)); j<x-abs(m-(x*2))+x; j++){
a[i][j]='+';
}
}
ans+=m-(x*2)+y;
}
cout<<ans<<'\n';
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cout<<a[i][j];
}
cout<<'\n';
}
}
else {
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[i][j]='+';
}
}
int x=m/2-(m%2==0), y=n/2+1;
// cout<<x<<' '<<y<<endl;
for(int i=0; i<y; i++){
for(int j=0; j<x; j++){
a[i][j]='-';
}
}
ans=n+x;
// cout<<x<<' '<<abs(n-(y*2))<<endl;
if(x>=abs(n-(y*2))){
for(int i=y-abs(n-(y*2)); i<y-abs(n-(y*2))+y; i++){
for(int j=x; j<x+x; j++){
a[i][j]='-';
}
}
ans+=n-(y*2)+x;
}
cout<<ans<<'\n';
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cout<<a[i][j];
}
cout<<'\n';
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
2 ms |
332 KB |
Wrong answer in test 38 5: 40 < 41 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
1340 KB |
Output is correct |
2 |
Correct |
19 ms |
1740 KB |
Output is correct |
3 |
Correct |
21 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
1324 KB |
Wrong answer in test 6 6: 8 < 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
2 ms |
332 KB |
Wrong answer in test 38 5: 40 < 41 |