# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1230856 | djsksbrbf | Red-blue table (IZhO19_stones) | C++20 | 0 ms | 0 KiB |
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define fi first
#define se second
#define pb push_back
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int tc; cin >> tc;
while(tc--){
int n, m; cin >> n >> m;
char a[n][m];
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++)a[i][j] = '+';
}
bool swit = 0;
if(n < m){
swap(n, m);
swit = 1;
}
vector <int> cnt(n, m);
bool cont = 1;
int r =0, c = 0;
ll ans = n;
while(cont){
int tmp = r;
for(int i = 1 ; i <= n / 2 + 1 ; i++){
cnt[tmp]--;
tmp++;
if(tmp >= n)tmp = 0;
}
tmp = r;
for(int i = 1 ; i <= n / 2 + 1 ; i++){
if(cnt[tmp] <= m / 2)cont = 0;
tmp++;
if(tmp >= n)tmp = 0;
}
if(!cont)break;
ans++;
for(int i = 1 ; i <= n ; i++){
if(swit)a[c][r] = '-';
else a[r][c] = '-';
r++;
if(r >= n)r = 0;
}
c++;
}
cout << ans << endl;
if(swit){
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++){
cout << (a[i][j] == '-' ? '+' : '-');
}
cout << endl;
}
}
else{
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++){
cout << a[i][j];
}
cout << endl;
}
}
}
return 0;
}