Submission #670211

# Submission time Handle Problem Language Result Execution time Memory
670211 2022-12-08T09:59:17 Z Vahaghar Red-blue table (IZhO19_stones) C++17
27 / 100
55 ms 1792 KB
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<set>
#include<string>

using namespace std;
using ll = long long;
using ull = unsigned long long;


int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll binpow(ll a, ll b)
{
	if (b == 0) return 1;
	ll res = binpow(a, b / 2);
	if (b % 2) return res * res * a;
	return res * res;
}

bool isprime(int n) {
	if (n == 1 || n == 0) return 0;
	for (int i = 2; i * i <= n; i++) if (!(n % i)) return 0;
	return 1;
}

void solve() {
    int n, m; cin >> n >> m;
    int mn = m + n;

    //if (n == m && n % 2) {
    //    cout << mn - 2 << endl;
    //}
    //else if (n == m && !(n % 2)) {
    //    cout << mn - 4 << endl;
    //}
    
    if (m <= 2 && m < n) {
        cout << n << endl;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cout << '+';
            }
            cout << endl;
        }
        return;
    }
    if (n <= 2) {
        cout << m << endl;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cout << '-';
            }
            cout << endl;
        }
        return;
    }
    if (n <= 4 && m <= 4) {
        cout << max(m, n) + 1 << endl;
    }
    else if (min(m, n) == 3 && !(max(m, n) % 2)) cout << max(m, n) + 1 << endl;
    else if ((n % 2) != (m % 2)) cout << mn - 3 << endl;
    else {
        if (n % 2) cout << mn - 2 << endl;
        else cout << mn - 4 << endl;
    }
    vector<vector<char>> v(n * m);

   if (n == m || (n == 3 && !(m % 2))) {
        for (int j = 0; j < m; j++) v[0].push_back('+');
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < m; j++) {
                v[i].push_back('-');
            }
        }

    }
    else if (!(n % 2) && m == 3) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) v[i].push_back('+');
            v[i].push_back('-');
        }

    }
    else  {
        for (int j = 0; j < m; j++) v[0].push_back('-');
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if ((i % 2)){
                    if (j < (m / 2 + 1)) {
                        v[i].push_back('+');
                    }
                    else v[i].push_back('-');
                }
                else {
                    if (j >= (m - m / 2 - 1)) {
                        v[i].push_back('+');
                    }
                    else v[i].push_back('-');
                }
            }
        }
        if (!(n % 2)) {
            for (int j = 0; j < m; j++) v[n - 1][j] = '-';
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cout << v[i][j];
        }
        cout << endl;
    }

    // 
    // ++
    // ++
    // 
    // ------
    // ------
    // ------
    // ------
    // ++++++
    // ++++++
    // ++++++
    // 
    // -----
    // -----
    // -----
    // +++++
    //
    // 
    // ----
    // ----
    // ++++
    // 
    // +++
    // ++-
    // ++-
    // ++-
    // 
    // 
    // ++
    // ++
    // ++
    // ++
    // ++
    // ++
    // 
    // ++-+-+
    // +----+
    // +-+-++
    // 
    // ++-+-
    // +----
    // +-+-+
    // 
    // ---
    // ++-
    // -++
    // ++-
    // -++
    // 
    // -----
    // +++--
    // --+++
    // -----
    // 
    // ++-
    // ++-
    // ++-
    // +++
    // 
    // 
    // 
    // -----
    // -----
    // --+++
    // +++--
    // 
    // -------
    // ++++---
    // ---++++
    // ++++---
    // ---++++
    // -------
    // 
    // --------
    // +++++---
    // ---+++++
    // +++++---
    // ---+++++
    // +++++---
    // ---+++++
    // 
    // 
    // 
    // 



}


int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int t; cin >> t; while(t--) 
	solve();




}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Incorrect 11 ms 340 KB Wrong answer in test 18 4: 18 < 19
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 1588 KB in the table A+B is not equal to 132
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 1792 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Incorrect 11 ms 340 KB Wrong answer in test 18 4: 18 < 19
5 Halted 0 ms 0 KB -