#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
bool arr[1005][1005];
void solve(){
int n,m;cin>>n>>m;
if(n>m){
int k = m-(m/2)-1;
int total = k*n/((n/2)+1);
int p=0;
for(int i=0;i<n;i++){
for(int g=0;g<k;g++){
arr[i][p]=1;
p = (p+1)%total;
}
}
cout<<n+total<<"\n";
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(arr[i][j]) cout<<"-";
else cout<<"+";
}
cout<<"\n";
}
}else{
int k = n-(n/2)-1;
int total = k*m/((m/2)+1);
int p=0;
for(int i=0;i<m;i++){
for(int g=0;g<k;g++){
arr[p][i]=1;
p = (p+1)%total;
}
}
cout<<m+total<<"\n";
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(arr[i][j]) cout<<"+";
else cout<<"-";
}
cout<<"\n";
}
}
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t;cin>>t;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
in the table A+B is not equal to 2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
1364 KB |
in the table A+B is not equal to 78 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
31 ms |
1368 KB |
in the table A+B is not equal to 36 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |