Submission #1198145

#TimeUsernameProblemLanguageResultExecution timeMemory
1198145brover29Logičari (COCI21_logicari)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> //qwerty47924692 using namespace std; using ll = long long; const ll N=1e5+29; const string br="617283"; #define sz(a)(ll)a.size() #define f first #define s second ll n,pr[N],dp[N][2][2][2][2],root,special; vector<ll>g[N]; ll get(ll x){ return(x==pr[x] ? x : pr[x]=get(pr[x])); }ll calc(ll v,ll me,ll up,ll rt,ll sp,ll pr=0){ if(dp[v][me][up][rt][sp]!=-1)return dp[v][me][up][rt][sp]; ll ok=1; if(v==root&&rt!=me)ok=0; if(v==special&&sp!=me)ok=0; if(v==special&&rt&&up)ok=0; if(!ok)return dp[v][me][up][rt][sp]=1e18; ll check=0; if(up)check=1; if(v==root&&sp)check=1; if(v==special&&rt)check=1; ll sum=me; ll diff=1e18; for(auto to:g[v]){ if(to==pr)continue; sum+=calc(to,0,me,rt,sp,v); diff=min(diff,calc(to,1,me,rt,sp,v)-calc(to,0,me,rt,sp,v)); } return min(1e18,dp[v][me][up][rt][sp]=(sum+diff*(!check))); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; memset(dp,-1,sizeof(dp)); for(ll i=1;i<=n;i++)pr[i]=i; for(ll i=1;i<=n;i++){ ll v,u; cin>>v>>u; if(get(v)==get(u)){ root=v; special=u; continue; } pr[get(v)]=get(u); g[v].push_back(u); g[u].push_back(v); } ll ans=1e18; for(ll rt=0;rt<2;rt++){ for(ll sp=0;sp<2;sp++){ ans=min(ans,calc(root,rt,0,rt,sp)); } } cout<<(ans==1e18 ? -1 : ans); }

Compilation message (stderr)

Main.cpp: In function 'll calc(ll, ll, ll, ll, ll, ll)':
Main.cpp:35:15: error: no matching function for call to 'min(double, ll&)'
   35 |     return min(1e18,dp[v][me][up][rt][sp]=(sum+diff*(!check)));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:35:15: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'll' {aka 'long long int'})
   35 |     return min(1e18,dp[v][me][up][rt][sp]=(sum+diff*(!check)));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:35:15: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'll' {aka 'long long int'})
   35 |     return min(1e18,dp[v][me][up][rt][sp]=(sum+diff*(!check)));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
Main.cpp:35:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   35 |     return min(1e18,dp[v][me][up][rt][sp]=(sum+diff*(!check)));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
Main.cpp:35:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   35 |     return min(1e18,dp[v][me][up][rt][sp]=(sum+diff*(!check)));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~