This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void solve(){
    int n, m;
    cin >> n >> m;
    bool swaped=false;
    if(n<m){
        swap(n, m);
        swaped=true;
    }
    char a[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            a[i][j]='+';
        }
    }
    int x = 0, ans=n, y=0;
    for(int i=0; i<(m-1)/2; i++){
        for(int j=0; j<m; j++){
            a[j][y]='-';
            x++;
            if(x==(n/2)+1){
                    ans++;
                    y++;
                    x=0;
             }
        }
    }
    cout << ans << "\n";
    if(!swaped){
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                cout << a[i][j];
            }
            cout << "\n";
        }
    }
    else{
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(a[j][i]=='+'){
                    cout << '-';
                }
                else{
                    cout << '+';
                }
            }
            cout << "\n";
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |