답안 #955787

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955787 2024-03-31T12:20:32 Z vjudge1 Pinball (JOI14_pinball) C++17
0 / 100
2 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
class Q{
public:
    long long int l, r, vo, den;
    Q(long long int o, long long int d, long long int v, long long int de): l(o), r(d), vo(v), den(de){}
};

int main()
{
    long long int m, n;
    cin>>m>>n;
    vector<Q>a;
    for(long long int i=0; i<m; i++)
    {
        long long int aa, bb, cc, dd;
        cin>>aa>>bb>>cc>>dd;
        aa--;
        bb--;
        cc--;
        a.push_back(Q(aa, bb, cc, dd));
    }
    long long int minn=LLONG_MAX;
    for(long long int i=0; i<pow(2, m); i++)
    {
        vector<long long int>comb;
        for(long long int j=0; j<m; j++)
        {
            if(i&(1<<j))
            {
                comb.push_back(j);
            }
        }
        /*cout<<"kombinbacija\n";
        for(int j=0; j<comb.size(); j++)
            cout<<comb[j]<<" ";
        cout<<endl;*/
        bool first=true, kiki=true;
        long long int kraj=-1, local_min=INT_MIN;
        //bool visited[comb.size()]={};
        for(long long int w=0; w<n; w++)
        {
            long long int curr=w, pari=0;
            for(long long int j=0; j<comb.size(); j++)
            {
                pari+=a[comb[j]].den;
                if(a[comb[j]].l<=curr && curr<=a[comb[j]].r)
                {
                    curr=a[comb[j]].vo;
                    /*if(!visited[j])
                    {

                        visited[j]=1;
                    }*/
                }
            }
            if(first==true)
            {
                kraj=curr;
                first=false;
            }
            else
            {
                if(kraj!=curr)
                {
                    kiki=0;
                    break;
                }
                else
                {
                    if(pari>local_min)
                        local_min=pari;
                }
            }
        }
        if(kiki)
        {
            if(local_min<minn)
                minn=local_min;
        }
        //cout<<endl<<local_min<<endl<<"-------------\n";
    }
    if(minn==INT_MAX)
        cout<<-1;
    else
        cout<<minn;

    return 0;
}

Compilation message

pinball.cpp: In function 'int main()':
pinball.cpp:44:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for(long long int j=0; j<comb.size(); j++)
      |                                    ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -