Submission #955822

# Submission time Handle Problem Language Result Execution time Memory
955822 2024-03-31T13:06:27 Z vjudge1 Pinball (JOI14_pinball) C++17
11 / 100
1 ms 756 KB
#include <bits/stdc++.h>
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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 756 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 756 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 756 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 756 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -