답안 #338446

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338446 2020-12-23T06:50:09 Z IZhO_2021_I_want_Silver Red-blue table (IZhO19_stones) C++14
43 / 100
35 ms 1516 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define show(a) cerr << #a <<" -> "<< a <<" "
#define nl cerr <<"\n"
//#define int ll

const int N = 1005;
const int oo = 1e9 + 5;

int n, m, cnt[N];
char a[N][N];

void solve() {
    cin >> n >> m;
    int ans = 0;
    if (n >= m) {
        ans += n;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                a[i][j] = '+';
            }
        }

        int pr = m / 2;
        if (m != 3 && m % 2 == 1) pr++;
        else if (m % 2 == 0) pr--;

        int pos = 1;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= (m - 1) / 2; ++j) {
                a[i][pos] = '-';
                ++cnt[pos];
                ++pos;
                if (pos == pr + 1) { pos = 1; }
            }
        }
        for (int i = 1; i <= pr; ++i) {
            if (cnt[i] >= (n / 2) + 1) { ++ans; }
            cnt[i] = 0;
        }
    }
    else {
        ans += m;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                a[i][j] = '-';
            }
        }

        int pr = n / 2;
        if (n != 3 && n % 2 == 1) pr++;
        else if (n % 2 == 0)pr--;

        int pos = 1;
        for (int j = 1; j <= m; ++j) {
            for (int i = 1; i <= (n - 1) / 2; ++i) {
                a[pos][j] = '+';
                ++cnt[pos];
                ++pos;
                if (pos == pr + 1) { pos = 1; }
            }
        }

        for (int i = 1; i <= pr; ++i) {
            if (cnt[i] >= (m / 2) + 1) { ++ans; }
            cnt[i] = 0;
        }
    }
    cout << ans <<"\n";
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cout << a[i][j];
        }
        cout <<"\n";
    }
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tests = 1;
	cin >> tests;
	while (tests --) {
		solve();
	}
	return 0;
}
/*
    Just Chalish!
*/

Compilation message

stones.cpp:109:8: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  109 |  main () {
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 1416 KB Wrong answer in test 97 21: 108 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 1516 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Incorrect 35 ms 1416 KB Wrong answer in test 97 21: 108 < 116
6 Halted 0 ms 0 KB -