제출 #424124

#제출 시각아이디문제언어결과실행 시간메모리
424124dooweyRed-blue table (IZhO19_stones)C++14
27 / 100
37 ms1284 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 1010;


vector<vector<char>> get(int n, int m, int &sol){
    sol = n;
    vector<vector<char>> sos;
    sos.resize(n);
    for(int i = 0 ; i < n; i ++ ){
        sos[i].resize(m, '-');
    }
    for(int i = 0 ; i < n; i ++ ){
        for(int j = 0; j < (m + 2) / 2; j ++ ){
            sos[i][j] = '+';
        }
    }
    int mod = (n+2)/2;
    int xx = 0;
    if(m > 2)
        sol += (m+1)/2-1;
    for(int take = 0 ; take < (m-3)/2; take ++ ){
        xx = take;
        for(int j = 0; j < mod; j ++ ){
            sos[take][j] = '-';
            sos[j][xx + (m+1)/2] = '+';
            xx ++ ;
            xx %= m/2;
        }
    }
    return sos;
}

void solve(){
    int n, m;
    cin >> n >> m;
    if(n >= m){
        int res = 0;
        vector<vector<char>> cc = get(n, m, res);
        cout << res << "\n";
        for(auto x : cc){
            for(auto y : x){
                cout << y;
            }
            cout << "\n";
        }
    }
    else{
        int res = 0;
        vector<vector<char>> cc = get(m, n, res);
        cout << res << "\n";
        for(int i = 0 ; i < n; i ++ ){
            for(int j = 0 ; j < m ; j ++ ){
                if(cc[j][i] == '-'){
                    cc[j][i] = '+';
                }
                else{
                    cc[j][i] = '-';
                }
                cout << cc[j][i];
            }
            cout << "\n";
        }

    }
}

int main(){
    fastIO;
    //freopen("test.txt","r",stdin);
    //freopen("oo.txt","w",stdout);
    int tc;
    cin >> tc;
    for(int iq = 1; iq <= tc; iq ++ ){
        solve();
    }
    return 0;
}

#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...