답안 #147734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147734 2019-08-30T14:00:16 Z theboatman Red-blue table (IZhO19_stones) C++17
0 / 100
6 ms 376 KB
#include <bits/stdc++.h>

#define y1 theboatman
#define make_struct(args...) {args}

using namespace std;

typedef long long ll;

const long long INF = 1e18 + 10;
const int inf = 1e9 + 10;
const int N = 1e6 + 10;

void solve1(int n, int m) {
    vector <vector <char> > ans(n, vector <char> (m, '-'));

    int res;
    if (n <= m) {
        vector <int> used(m);

        res = m;
        for(int i = 0; i < n; i++) {
            vector <pair <int, int> > pos;
            for(int j = 0; j < m; j++) {
                if (used[j] < (n - 1) / 2) {
                    pos.push_back(make_pair(used[j], j));
                }
            }

            if (pos.size() < (m / 2) + 1) {
                break;
            }
            else {
                sort(pos.begin(), pos.end());

                for(int j = 0; j < (m / 2) + 1; j++) {
                    used[pos[j].second]++;
                    ans[i][pos[j].second] = '+';
                }
            }

            res++;
        }
    }
    else {
        vector <int> used(n);

        res = n;
        for(int i = 0; i < m; i++) {
            vector <pair <int, int> > pos;
            for(int j = 0; j < n; j++) {
                if (used[j] < (m - 1) / 2) {
                    pos.push_back(make_pair(used[j], j));
                }
            }

            if (pos.size() < (n / 2) + 1) {
                break;
            }
            else {
                sort(pos.begin(), pos.end());

                for(int j = 0; j < (n / 2) + 1; j++) {
                    used[pos[j].second]++;
                    ans[pos[j].second][i] = '+';
                }
            }

            res++;
        }
    }

    cout << res << "\n";
    for(auto i : ans) {
        for(auto j : i) {
            cout << j;
        }
        cout << "\n";
    }
}

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

    if (n <= 50 && m <= 50) {
        solve1(n, m);
    }
    else {
        cout << "0\n";
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int test;
    cin >> test;

    while(test--) {
        solve();
    }

    return 0;
}

/*
*/

Compilation message

stones.cpp: In function 'void solve1(int, int)':
stones.cpp:30:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (pos.size() < (m / 2) + 1) {
                 ~~~~~~~~~~~^~~~~~~~~~~~~
stones.cpp:57:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (pos.size() < (n / 2) + 1) {
                 ~~~~~~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 248 KB in the table A+B is not equal to 2
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB in the table A+B is not equal to 2
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 248 KB in the table A+B is not equal to 2
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Wrong answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Wrong answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 248 KB in the table A+B is not equal to 2