Submission #1172013

#TimeUsernameProblemLanguageResultExecution timeMemory
1172013Hurryup_7735Red-blue table (IZhO19_stones)C++20
0 / 100
15 ms1860 KiB
//In The Name Of ALLAH!
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define pf push_front
#define speedyboy ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define bpc __builtin_popcount
#define all(x) x.begin() , x.end()
#define allr(x) x.rbegin() , x.rend()
#define F first
#define S second
#define pll pair<ll , ll>
#define turtle tuple<ll , ll , ll>
#define pss pair<string , string>
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define ordered_set tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update>


const ll sz = 3e3 + 5 , INF = 1e18 ,  MOD = 998244353;
char a[sz][sz] , b[sz][sz];

ll mask , i , j , o;
void solve(){
    ll n , m;
    cin >> n >> m;
    bool ok = false;
    if(n > m){
        swap(n , m);
        ok = true;
    }
    for(i = 0 ; i < n ; i++){
        for(j = 0 ; j < m ; j++){
            a[i][j] = '-';
        }
    }
    ll x = (m + 2) / 2;
    for(i = 0 ; i < n ; i++){
        if(i % 2 == 0){
            for(j = 0 ; j < x ; j++) a[i][j] = '+';
        }
        else{
            for(j = m - 1 ; j >= m - x ; j--) a[i][j] = '+';
        }
    }
    if(!ok){
        ll cnt = 0;
        for(i = 0 ; i < n ; i++){
            ll pos = 0 , neg = 0;
            for(j = 0 ; j < m ; j++){
                pos += (a[i][j] == '+');
                neg += (a[i][j] == '-');
            }
            if(pos > neg) cnt++;
        }
        for(j = 0 ; j < m ; j++){
            ll pos = 0 , neg = 0;
            for(i = 0 ; i < n ; i++){
                pos += (a[i][j] == '+');
                neg += (a[i][j] == '-');
            }
            if(neg > pos) cnt++;
        }
        cout << cnt << endl;
        for(i = 0 ; i < n ; i++){
            for(j = 0 ; j < m ; j++){
                cout << a[i][j];
            }
            cout << endl;
        }
    }
    else{
        for(i = 0 ; i < n ; i++){
            for(j = 0 ; j < m ; j++){
                b[j][i] = a[i][j];
                if(b[j][i] == '-') b[j][i] = '+';
                else               b[j][i] = '-';
            }
        }
        swap(n , m);
        ll cnt = 0;
        for(i = 0 ; i < n ; i++){
            ll pos = 0 , neg = 0;
            for(j = 0 ; j < m ; j++){
                pos += (a[i][j] == '+');
                neg += (a[i][j] == '-');
            }
            if(pos > neg) cnt++;
        }
        for(j = 0 ; j < m ; j++){
            ll pos = 0 , neg = 0;
            for(i = 0 ; i < n ; i++){
                pos += (a[i][j] == '+');
                neg += (a[i][j] == '-');
            }
            if(neg > pos) cnt++;
        }
        cout << cnt << endl;
        for(i = 0 ; i < n ; i++){
            for(j = 0 ; j < m ; j++){
                cout << b[i][j];
            }
            cout << endl;
        }
    }
}

signed main(){
    speedyboy;
    //open;
    ll t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...