답안 #168865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168865 2019-12-16T17:57:50 Z ptreap Red-blue table (IZhO19_stones) C++14
53 / 100
86 ms 1920 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <iomanip>
#include <stdio.h>
#include <ctime>
#include <fstream>
#include <chrono>
#define _GLIBCXX_DEBUG
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)x.size()
#define pb push_back;
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"
typedef int supertype;


using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    int bestI = 0, best = 0;
    for (int i = 0; i <= n; i++) {
        int now = i, need = max(0LL, n / 2 + 1 - (n - i));
        if (need == 0)
            now += m;
        else {
            int plasts = m - (m / 2 + 1);
            now += min(m, i / need * plasts);
        }
        if (now > best) {
            best = now;
            bestI = i;
        }
    }
    cout << best << endl;
    vector <vector <char>> ans(n, vector <char>(m, '-'));
    for (int i = 0; i < bestI; i++) {
        for (int j = 0; j < m; j++) {
            ans[i][j] = '+';
        }
    }
    int need = max(0LL, n / 2 + 1 - (n - bestI));
    if (need > 0) {
        vector <int> canGive(bestI, m - (m / 2 + 1));
        for (int j = 0; j < m; j++) {
            int now = need;
            for (int i = 0; i < bestI && now > 0; i++) {
                if (canGive[i] > 0) {
                    now--;
                    canGive[i]--;
                    ans[i][j] = '-';
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cout << ans[i][j];
        }
        cout << endl;
    }
}


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    //freopen("sort.in", "r", stdin);
    //freopen("sort.in", "r", stdin);

    int tests = 1;
    cin >> tests;
    while (tests--) {
        solve();
    }

    return 0;
}


/*

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 14 ms 376 KB Output is correct
4 Incorrect 23 ms 376 KB Wrong answer in test 38 5: 40 < 41
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 1396 KB Output is correct
2 Correct 35 ms 1656 KB Output is correct
3 Correct 35 ms 1920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 1368 KB Output is correct
2 Correct 35 ms 1528 KB Output is correct
3 Correct 29 ms 1344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 14 ms 376 KB Output is correct
4 Incorrect 23 ms 376 KB Wrong answer in test 38 5: 40 < 41