#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define f first
#define s second
void answer(){
int n, m;
cin >> n >> m;
bool f = 0;
if(n < m){
swap(n, m);
f = 1;
}
int ret = 0;
int a[n][m];
memset(a, 0, sizeof(a));
for(int i = 0, c = n / 2; i < (m - 1) / 2; i++)
for(int j = 0; j < n; j++, c--){
a[j][ret] = 1;
if(!c){
ret++;
c = n / 2 + 1;
}
}
ret += n;
if(f) swap(n, m);
cout << ret << endl;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << ((f ? !a[j][i] : a[i][j]) ? '-' : '+');
}
cout << endl;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for(int i = 0; i < t; i++) answer();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
1400 KB |
Output is correct |
2 |
Correct |
29 ms |
3832 KB |
Output is correct |
3 |
Correct |
30 ms |
3960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
1400 KB |
Output is correct |
2 |
Correct |
27 ms |
3192 KB |
Output is correct |
3 |
Correct |
26 ms |
2424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
400 KB |
Output is correct |
5 |
Correct |
34 ms |
1400 KB |
Output is correct |
6 |
Correct |
29 ms |
3832 KB |
Output is correct |
7 |
Correct |
30 ms |
3960 KB |
Output is correct |
8 |
Correct |
31 ms |
1400 KB |
Output is correct |
9 |
Correct |
27 ms |
3192 KB |
Output is correct |
10 |
Correct |
26 ms |
2424 KB |
Output is correct |
11 |
Correct |
15 ms |
504 KB |
Output is correct |
12 |
Correct |
27 ms |
2808 KB |
Output is correct |
13 |
Correct |
26 ms |
2424 KB |
Output is correct |
14 |
Correct |
22 ms |
1656 KB |
Output is correct |
15 |
Correct |
32 ms |
5240 KB |
Output is correct |
16 |
Correct |
26 ms |
3960 KB |
Output is correct |
17 |
Correct |
13 ms |
1912 KB |
Output is correct |