Submission #1101866

#TimeUsernameProblemLanguageResultExecution timeMemory
1101866simona1230Toll (BOI17_toll)C++17
Compilation error
0 ms0 KiB
// Online C++ compiler to run C++ program online #include <bits/stdc++.h> using namespace std; int k,n,m,o; vector<pair<int,int> > v[200001],op[200001]; void read() { cin>>k>>n>>m>>o; for(int i=1;i<=m;i++) { int a,b,t; cin>>a>>b>>t; v[a].push_back({b,t}); op[b].push_back({a,t}); } } pair<int,int> q[200001]; long long p[200001]; void subt1() { for(int i=0;i<n;i++) { p[i+1]=1e9; for(int j=0;j<v[i].size();j++) { int nb=v[i][j].second; p[i+1]=min(p[i+1],nb); } p[i+1]+=p[i]; } for(int i=1;i<=o;i++) if(p[q[i].second]-p[q[i].first]<1e9)cout<<p[q[i].second]-p[q[i].first]<<endl; else cout<<-1<<endl; exit(0); } int dp[200001]; void subt2() { for(int i=1;i<n;i++) { dp[i]=1e9; for(int j=0;j<op[i].size();j++) { pair<int,int> nb=op[i][j]; dp[i]=min(dp[i],dp[nb.first]+nb.second); } } for(int i=1;i<=o;i++) cout<<dp[q[i].second]<<endl; } int lf=0; void solve() { for(int i=1;i<=o;i++) { cin>>q[i].first>>q[i].second; lf=min(lf,q[i].first); } if(k==1)subt1(); if(lf==1)subt2(); } int main() { read(); solve(); return 0; }

Compilation message (stderr)

toll.cpp: In function 'void subt1()':
toll.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int j=0;j<v[i].size();j++)
      |                     ~^~~~~~~~~~~~
toll.cpp:31:33: error: no matching function for call to 'min(long long int&, int&)'
   31 |             p[i+1]=min(p[i+1],nb);
      |                                 ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from toll.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
toll.cpp:31:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |             p[i+1]=min(p[i+1],nb);
      |                                 ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from toll.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
toll.cpp:31:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |             p[i+1]=min(p[i+1],nb);
      |                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from toll.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
toll.cpp:31:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |             p[i+1]=min(p[i+1],nb);
      |                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from toll.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
toll.cpp:31:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |             p[i+1]=min(p[i+1],nb);
      |                                 ^
toll.cpp: In function 'void subt2()':
toll.cpp:49:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for(int j=0;j<op[i].size();j++)
      |                     ~^~~~~~~~~~~~~