답안 #955821

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955821 2024-03-31T13:05:44 Z vjudge1 Pinball (JOI14_pinball) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long

int m,n;

bool ok(vector<pair<int,pair<int,pair<int,int>>>> res)
{
    int s, f;
    s=res[res.size()-1].first;
    f=res[res.size()-1].second.first;
    res.pop_back();
    while (!res.empty())
    {
        if (s<=res[res.size()-1].second.second.first && res[res.size()-1].second.second.first<=f)
        {
            s=min(s,res[res.size()-1].first);
            f=max(f,res[res.size()-1].second.first);
        }
        else
            return 0;
        res.pop_back();
    }
    if (s==1 && f==n)
        return 1;
    return 0;
}

int main()
{
    ll r=LLONG_MAX;
    vector <pair<int,pair<int,pair<int,int>>>> v;
    vector<pair<int,pair<int,pair<int,int>>>> res;
    cin>>m>>n;
    for (int i=0;i<m;i++)
    {
        int a, b, c, d;
        cin>>a>>b>>c>>d;
        v.push_back({a,{b,{c,d}}});
    }
    for (int i=1;i<(int)pow(2,m);i++)
    {
        res.clear();
        int pom=1;
        ll p=0;
        while (pom<=i)
        {
            int k=pom&i;
            if (k!=0)
            {
                int c=0;
                while (!(k%2))
                {
                    c++;
                    k/=2;
                }
                p+=v[c].second.second.second;
                res.push_back(v[c]);
            }
            pom=pom<<1;
        }
        if (p<r && ok(res))
            r=p;
    }
    if (r==LLONG_MAX)
        r=-1;
    cout<<r;

    return 0;
}

Compilation message

pinball.cpp: In function 'int main()':
pinball.cpp:33:10: error: 'LLONG_MAX' was not declared in this scope
   33 |     ll r=LLONG_MAX;
      |          ^~~~~~~~~
pinball.cpp:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    3 | #include <cmath>
  +++ |+#include <climits>
    4 | using namespace std;