#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 100000000000000000
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pp push
typedef long long ll;
using namespace std;
char ans[1001][1001];
int main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
int test;
cin >> test;
while(test--){
int n,m;
cin >> n >> m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)
ans[i][j]='+';
}
int k=max(n,m)+(min(n,m)-((min(n,m)/2)+1))*max(n,m)/(max(n,m)/2+1);
cout << k << '\n';
if(n>m){
for(int i=m+n-k;i<m;i++){
for(int j=0;j<=(n/2);j++){
ans[(j+i*(n/2+1))%n][i]='-';
}
}
}
else{
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
ans[i][j]='-';
}
}
for(int i=m+n-k;i<n;i++){
for(int j=0;j<=(m/2);j++){
ans[i][(j+i*(m/2+1))%m]='+';
}
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout << ans[i][j];
}
cout << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
1516 KB |
Output is correct |
2 |
Correct |
34 ms |
2156 KB |
Output is correct |
3 |
Correct |
37 ms |
2156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
1516 KB |
Output is correct |
2 |
Correct |
30 ms |
2028 KB |
Output is correct |
3 |
Correct |
27 ms |
1644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
36 ms |
1516 KB |
Output is correct |
6 |
Correct |
34 ms |
2156 KB |
Output is correct |
7 |
Correct |
37 ms |
2156 KB |
Output is correct |
8 |
Correct |
40 ms |
1516 KB |
Output is correct |
9 |
Correct |
30 ms |
2028 KB |
Output is correct |
10 |
Correct |
27 ms |
1644 KB |
Output is correct |
11 |
Correct |
9 ms |
620 KB |
Output is correct |
12 |
Correct |
28 ms |
1920 KB |
Output is correct |
13 |
Correct |
30 ms |
2028 KB |
Output is correct |
14 |
Correct |
23 ms |
1772 KB |
Output is correct |
15 |
Correct |
36 ms |
2284 KB |
Output is correct |
16 |
Correct |
27 ms |
1900 KB |
Output is correct |
17 |
Correct |
12 ms |
1388 KB |
Output is correct |