Submission #896405

# Submission time Handle Problem Language Result Execution time Memory
896405 2024-01-01T11:38:39 Z Aiperiii Pinball (JOI14_pinball) C++14
11 / 100
1000 ms 47392 KB
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);
    int n,m;
    cin>>m>>n;
    vector <int> a(m),b(m),c(m),d(m);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    int mn=1e18;
    for(int i=0;i<(1<<m);i++){
        vector <int> v;
        int sum=0;
        for(int j=0;j<m;j++){
            if((i & (1<<j))!=0){
                v.pb(j);
                sum+=d[j];
            }
        }
        set <int> st;
        for(int j=1;j<=n;j++){
            int cur=j;
            int s=0;
            while(true){
                bool flag=false;
                for(int t=s;t<v.size();t++){
                    int k=v[t];
                    if(a[k]<=cur && cur<=b[k]){
                        cur=c[k];
                        flag=true;
                        s=t+1;
                        break;
                    }
                }
                if(!flag){
                    st.insert(cur);break;
                }
            }
            if(v.size()==m)cout<<"\n";
        }
        if(st.size()==1)mn=min(mn,sum);
    }
    
    if(mn==1e18)cout<<-1<<"\n";
    else cout<<mn<<"\n";
}

Compilation message

pinball.cpp: In function 'int main()':
pinball.cpp:33:30: 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]
   33 |                 for(int t=s;t<v.size();t++){
      |                             ~^~~~~~~~~
pinball.cpp:46:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   46 |             if(v.size()==m)cout<<"\n";
      |                ~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 31 ms 348 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 18 ms 348 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 31 ms 348 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 18 ms 348 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Execution timed out 1054 ms 47392 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 31 ms 348 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 18 ms 348 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Execution timed out 1054 ms 47392 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 31 ms 348 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 18 ms 348 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Execution timed out 1054 ms 47392 KB Time limit exceeded
10 Halted 0 ms 0 KB -