QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296294#7991. 最小环stcmuyCompile Error//C++201.8kb2024-01-02 18:00:352024-01-02 18:00:35

Judging History

你现在查看的是最新测评结果

  • [2024-01-02 18:00:35]
  • 评测
  • [2024-01-02 18:00:35]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define i64 long long
#define i128 __int128
#define endl '\n'
using namespace std;
const i64 mod = 1e18;
const int maxn = 3e5+10;
struct node {int u,v,w;};
signed main()
{
    IOS;
    int n,m;
    cin >> n >> m;
    vector<node> e;
    i64 ans = mod;
    for(int i = 1; i <= m; ++i)
    {
        int x,y,z;
        cin >> x >> y >> z;
        if(x == y)
        {
            ans = min(ans,z);
            continue;
        }
        e.push_back((node){x,y,z});
    }
    vector<int> f(n+1);
    for(int i = 1; i <= n; ++i) f[i] = i;
    auto get = [&](auto self,int x) -> int
    {
        if(f[x] == x) return x;
        return f[x] = self(self,f[x]);
    };
    sort(e.begin(),e.end(),[&](node a,node b){return a.w < b.w;});
    vector<vector<pair<int,int>>> v(n+1);
    vector<node> qs;
    for(node &a : e)
    {
        int s1 = get(get,a.u);
        int s2 = get(get,a.v);
        if(s1 != s2)
        {
            v[a.u].push_back({a.v,a.w});
            f[s1] = s2;
        }
        else qs.push_back(a);
    }
    for(node &a : qs)
    {
        vector<i64> dis(n+1,mod);
        dis[a.v] = 0;
        priority_queue<pair<int,int>> q;
        q.push({0,a.v});
        while(q.size())
        {
            int x = q.top().second;
            q.pop();
            for(auto [u,val] : v[x])
            {
                if(dis[u] > dis[x] + val)
                {
                    dis[u] = dis[x] + val;
                    q.push({-dis[u],u});
                }
            }
        }
        ans = min(ans,dis[a.u] + a.w);
    }
    if(ans == mod) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



Details

answer.code: In function ‘int main()’:
answer.code:23:22: error: no matching function for call to ‘min(long long int&, int&)’
   23 |             ans = min(ans,z);
      |                   ~~~^~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code: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:
answer.code:23:22: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   23 |             ans = min(ans,z);
      |                   ~~~^~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code: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:
answer.code:23:22: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   23 |             ans = min(ans,z);
      |                   ~~~^~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code: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:
answer.code:23:22: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   23 |             ans = min(ans,z);
      |                   ~~~^~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code: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:
answer.code:23:22: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   23 |             ans = min(ans,z);
      |                   ~~~^~~~~~~