제출 #1217084

#제출 시각아이디문제언어결과실행 시간메모리
1217084badge881Olympiads (BOI19_olympiads)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100, M = 1e5 + 10, K = 52, MX = 30;

int n, k, c;
array<int, 6> a[N];

struct Partition
{
    vector<pair<int, int>> ban;
    int fix, cost;
    vector<int> span;

private:
    int val(vector<int> &v)
    {
        int cost = 0;
        for (int i = 0; i < k; ++i)
        {
            int x = 0;
            for (int j : v)
                x = max(x, a[j][i]);
            cost += x;
        }
        return cost;
    }

public:
    Partition(vector<pair<int, int>> t, int fx) : fix(fx), ban(t)
    {
        cost = 0;
        for (int i = 0; i < k; ++i)
        {
            bool nice = 0;
            int best = 0;
            for (int j = 1; j <= n; ++j)
                if (ban[j].first == 1 && ban[j].second == i)
                {
                    nice = 1;
                    span.push_back(j);
                    break;
                }
                else if (ban[j].first == 0)
                    best = best == 0 ? j : (a[j][i] > a[best][i] ? j : best);

            if (!nice)
            {
                if (best == 0)
                    break;
                span.push_back(best);
                ban[best] = {1, i};
            }
        }
        cost = val(span);
    }
    bool operator<(const Partition &other) const
    {
        return cost < other.cost;
    }
};

signed main()
{
    scanf("%d%d%d", &n, &k, &c);
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j < k; ++j)
            scanf("%d", &a[i][j]);
    priority_queue<Partition> Q;
    vector<pair<int, int>> T(n + 1);
    Partition X(T, 0);
    Q.push(X);
    while (c--)
    {
        auto cur = Q.top();
        Q.pop();
        if (c == 0)
        {
            printf("%d\n", cur.cost);
            return;
        }
        for (int j = cur.fix; j < k; ++j)
        {
            vector<pair<int, int>> T = cur.ban;
            T[cur.span[j]].first = 2;
            Partition p(T, j);
            if (p.span.size() == k)
                Q.push(p);
        }
    }
}

컴파일 시 표준 에러 (stderr) 메시지

olympiads.cpp: In function 'int main()':
olympiads.cpp:79:13: error: return-statement with no value, in function returning 'int' [-fpermissive]
   79 |             return;
      |             ^~~~~~
olympiads.cpp:64:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |     scanf("%d%d%d", &n, &k, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp:67:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |             scanf("%d", &a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~