# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1203989 | PlayVoltz | Red-blue table (IZhO19_stones) | C++20 | 0 ms | 0 KiB |
#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while (t--){
int n, m;
cin>>n>>m;
bool rotate=0;
if (n<m)swap(n, m), rotate=1;
vector<vector<char> > res(n, vector<char>(m, '+'));
int ans=n, c=0, x=0, y=0;
for (int i=0; i<n*((m-1)/2); ++i){
res[x][y]='-', ++c;
if (c>=(n-(n-1)/2))c=0, ++y, ++ans;
x=(x+1)%n;
}
cout<<ans<<"\n";
if (!rotate)for (int i=0; i<n; ++i, cout<<"\n")for (int j=0; j<m; ++j)cout<<res[i][j];
else for (int i=0; i<m; ++i, cout<<"\n")for (int j=0; j<n; ++j)cout<<(res[j][i]=='+'?'-':'+');
}
}