제출 #1158238

#제출 시각아이디문제언어결과실행 시간메모리
1158238sunflower휴가 (IOI14_holiday)C++17
컴파일 에러
0 ms0 KiB
#ifndef SUN
#include "holiday.h"
#endif // SUN

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define MASK(x) (1LL << (x))
#define BIT(x, i) (((x) >> (i)) & 1)
#define SZ(x) ((int) (x).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define debug(x) cerr << "[" << #x << " = " << (x) << "]" << endl

#define left    __left
#define right   __right
#define prev    __prev
#define fi      first
#define se      second

template <class X, class Y>
    bool maximize(X &x, Y y) {
        if (x < y) return x = y, true;
        else return false;
    }

template <class X, class Y>
    bool minimize(X &x, Y y) {
        if (x > y) return x = y, true;
        else return false;
    }

int numPlace, start, days;

#define MAX_N 100'100
ll a[MAX_N + 2];

namespace subtask1 {
    bool check() {
        return (numPlace <= 20);
    }

    ll solve() {
        ll ans = 0;
        FOR(mask, 0, MASK(numPlace) - 1) {
            if (BIT(mask, start) == 0) continue;

            int minBit = -1, maxBit = -1; /// position;
            int numBit = 0;
            ll res = 0;
            FOR(i, 0, numPlace - 1) {
                if (BIT(mask, i)) {
                    ++numBit;
                    maxBit = i;
                    if (minBit == -1) minBit = i;
                    res += a[i];
                }
            }

            if (numBit + maxBit - minBit + min(maxBit - start, start - minBit) <= days) {
                maximize(ans, res);
            }

            /// case2: don't visit at start;
            numBit--;
            res -= a[start];
            if (numBit + maxBit - minBit + min(maxBit - start, start - minBit) <= days) {
                maximize(ans, res);
            }
        }

        return ans;
    }
}

long long int findMaxAttraction(int __n, int __start, int __d, ll attraction[]) {
    numPlace = __n;
    start = __start;
    days = __d;
    FOR(i, 0, numPlace - 1) a[i] = attraction[i];

    if (subtask1 :: check()) return subtask1 :: solve();
}

#ifdef SUN

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    freopen("test.inp","r",stdin);
    freopen("test.out","w",stdout);
    cin >> numPlace >> start >> days;
    FOR(i, 0, numPlace - 1) cin >> a[i];

    cout << findMaxAttraction(numPlace, start, days, a);
    return 0;
}
#endif // SUN

/* Discipline - Calm */


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

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, long long int*)':
holiday.cpp:85:1: warning: control reaches end of non-void function [-Wreturn-type]
   85 | }
      | ^
/usr/bin/ld: /tmp/ccQZ0dOq.o: in function `main':
grader.cpp:(.text.startup+0xaf): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status