Submission #53807

# Submission time Handle Problem Language Result Execution time Memory
53807 2018-07-01T08:36:58 Z TadijaSebez Pinball (JOI14_pinball) C++11
Compilation error
0 ms 0 KB
#include <stdio.h>
#include <map>
#include <algorithm>
using namespace std;
#define ll long long
const int N=200050;
const int M=32*N*2;
const ll inf=9e18;
int ls[M],rs[M],tsz,root,root2;ll Min[M];
void Set(int &c, int ss, int se, int qi, ll val)
{
    if(!c) c=++tsz,Min[c]=val;
    Min[c]=min(Min[c],val);
    if(ss==se) return;
    int mid=ss+se>>1;
    if(qi<=mid) Set(ls[c],ss,mid,qi,val);
    else Set(rs[c],mid+1,se,qi,val);
}
ll Get(int c, int ss, int se, int qs, int qe)
{
    if(qs>se || ss>qe) return inf;
    if(qs<=ss && qe>=se) return Min[c];
    int mid=ss+se>>1;
    return min(Get(ls[c],ss,mid,qs,qe),Get(rs[c],mid+1,se,qs,qe));
}
map<int,ll> dp1,dp2;
int a[N],b[N],c[N],d[N];
ll d1[N],d2[N];
int main()
{
    Min[0]=inf;
    int n,m,i;
    scanf("%i %i",&n,&m);
    for(i=1;i<=n;i++) scanf("%i %i %i %i",&a[i],&b[i],&c[i],&d[i]),dp1[c[i]]=dp2[c[i]]=inf,d1[i]=d2[i]=inf;
    for(i=n;i>=1;i--)
    {
        if(a[i]==1)
        {
            dp1[c[i]]=min(dp1[c[i]],d[i]);
            Set(root,1,m,c[i],d[i]);s
        }
        else
        {
            dp1[c[i]]=min(dp1[c[i]],Get(root,1,m,a[i],b[i])+d[i]);
            Set(root,1,m,c[i],dp1[c[i]]);
        }
        d1[i]=dp1[c[i]];
    }
    for(i=n;i>=1;i--)
    {
        if(b[i]==m)
        {
            dp2[c[i]]=min(dp2[c[i]],d[i]);
            Set(root2,1,m,c[i],d[i]);
        }
        else
        {
            dp2[c[i]]=min(dp2[c[i]],Get(root2,1,m,a[i],b[i])+d[i]);
            Set(root2,1,m,c[i],dp2[c[i]]);
        }
        d2[i]=dp2[c[i]];
    }
    ll sol=inf;
    for(i=1;i<=n;i++) sol=min(sol,dp1[c[i]]+dp2[c[i]]),sol=min(sol,d1[i]+d2[i]-d[i]);
    if(sol>=inf) printf("-1\n");
    else printf("%lld\n",sol);
    return 0;
}

Compilation message

pinball.cpp: In function 'void Set(int&, int, int, int, long long int)':
pinball.cpp:15:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid=ss+se>>1;
             ~~^~~
pinball.cpp: In function 'long long int Get(int, int, int, int, int)':
pinball.cpp:23:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid=ss+se>>1;
             ~~^~~
pinball.cpp: In function 'int main()':
pinball.cpp:39:41: error: no matching function for call to 'min(std::map<int, long long int>::mapped_type&, int&)'
             dp1[c[i]]=min(dp1[c[i]],d[i]);
                                         ^
In file included from /usr/include/c++/7/bits/stl_tree.h:63:0,
                 from /usr/include/c++/7/map:60,
                 from pinball.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
pinball.cpp:39:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             dp1[c[i]]=min(dp1[c[i]],d[i]);
                                         ^
In file included from /usr/include/c++/7/bits/stl_tree.h:63:0,
                 from /usr/include/c++/7/map:60,
                 from pinball.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
pinball.cpp:39:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             dp1[c[i]]=min(dp1[c[i]],d[i]);
                                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from pinball.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
pinball.cpp:39:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             dp1[c[i]]=min(dp1[c[i]],d[i]);
                                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from pinball.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
pinball.cpp:39:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             dp1[c[i]]=min(dp1[c[i]],d[i]);
                                         ^
pinball.cpp:40:37: error: 's' was not declared in this scope
             Set(root,1,m,c[i],d[i]);s
                                     ^
pinball.cpp:53:41: error: no matching function for call to 'min(std::map<int, long long int>::mapped_type&, int&)'
             dp2[c[i]]=min(dp2[c[i]],d[i]);
                                         ^
In file included from /usr/include/c++/7/bits/stl_tree.h:63:0,
                 from /usr/include/c++/7/map:60,
                 from pinball.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
pinball.cpp:53:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             dp2[c[i]]=min(dp2[c[i]],d[i]);
                                         ^
In file included from /usr/include/c++/7/bits/stl_tree.h:63:0,
                 from /usr/include/c++/7/map:60,
                 from pinball.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
pinball.cpp:53:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             dp2[c[i]]=min(dp2[c[i]],d[i]);
                                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from pinball.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
pinball.cpp:53:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             dp2[c[i]]=min(dp2[c[i]],d[i]);
                                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from pinball.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
pinball.cpp:53:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             dp2[c[i]]=min(dp2[c[i]],d[i]);
                                         ^
pinball.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i %i",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
pinball.cpp:34:91: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++) scanf("%i %i %i %i",&a[i],&b[i],&c[i],&d[i]),dp1[c[i]]=dp2[c[i]]=inf,d1[i]=d2[i]=inf;
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~