#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int t;
char arr[1005][1005];
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
for(int e=1;e<=t;e++){
int n,m,ans;
cin >> n >> m;
if(n>=m){
int rem = m-m/2-1, need = n-(n-n/2-1);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
arr[i][j] = '+';
}
}
int curr=1,cnt=0;
for(int c=0;c<rem*n;c++){
if(cnt==need){
cnt = 0;
curr++;
}
arr[c%n+1][curr] = '-';
cnt++;
}
if(cnt==need){
cnt = 0;
curr++;
}
ans = n+curr-1LL;
}
else{
int rem = n-n/2-1, need = m-(m-m/2-1);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
arr[i][j] = '-';
}
}
int curr=1,cnt=0;
for(int c=0;c<rem*m;c++){
if(cnt==need){
cnt = 0;
curr++;
}
arr[curr][c%m+1] = '+';
cnt++;
}
if(cnt==need){
cnt = 0;
curr++;
}
ans = m+curr-1LL;
}
cout << ans << "\n";
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cout << arr[i][j];
}
cout << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
432 KB |
Output is correct |
4 |
Correct |
2 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
1440 KB |
Output is correct |
2 |
Correct |
19 ms |
1856 KB |
Output is correct |
3 |
Correct |
17 ms |
1996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
1364 KB |
Output is correct |
2 |
Correct |
17 ms |
1752 KB |
Output is correct |
3 |
Correct |
15 ms |
1564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
432 KB |
Output is correct |
4 |
Correct |
2 ms |
328 KB |
Output is correct |
5 |
Correct |
24 ms |
1440 KB |
Output is correct |
6 |
Correct |
19 ms |
1856 KB |
Output is correct |
7 |
Correct |
17 ms |
1996 KB |
Output is correct |
8 |
Correct |
20 ms |
1364 KB |
Output is correct |
9 |
Correct |
17 ms |
1752 KB |
Output is correct |
10 |
Correct |
15 ms |
1564 KB |
Output is correct |
11 |
Correct |
5 ms |
596 KB |
Output is correct |
12 |
Correct |
16 ms |
1880 KB |
Output is correct |
13 |
Correct |
22 ms |
1916 KB |
Output is correct |
14 |
Correct |
13 ms |
1588 KB |
Output is correct |
15 |
Correct |
21 ms |
2296 KB |
Output is correct |
16 |
Correct |
17 ms |
1748 KB |
Output is correct |
17 |
Correct |
7 ms |
1228 KB |
Output is correct |