Submission #1012219

#TimeUsernameProblemLanguageResultExecution timeMemory
1012219codefoxRobot (JOI21_ho_t4)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")

#define int long long
#define arr array<int, 4>

vector<vector<arr>> graph;
vector<vector<int>> fc;
vector<int> d1;
vector<int> d2;
vector<int> d3;
vector<int> d4;


int32_t main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;

    graph.assign(n, vector<arr>());
    fc.assign(n, -1);
    d1.assign(n, 1e18);
    d2.assign(n, 1e18);
    d3.assign(n, 1e18);
    d4.assign(n, 1e18);

    for (int j = 0; j < m; j++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--;
        graph[a].push_back({b, c, d, 0});
    }

    priority_queue<arr, vector<arr>, greater<arr>> pq;
    pq.push({0, m+1, 0, 0});
    while (pq.size())
    {
        arr a = pq.top();
        pq.pop();
        int i = a[2];
        int c = a[1];
        int d = a[0];
        int p = a[3];
        int b = 0;
        for (int ele:fc[i])
        {
            if (ele ==c) b=1;
        }
        if (b) continue;
        if (d4[i]<=d) continue;
        fc[i].push_back(c);
        if (d1[i]==1e18) d1[i] = d;
        else if (d2[i]==1e18) d2[i] = d;
        else if (d3[i]==1e18) d3[i] = d;
        else if (d4[i]==1e18) d4[i] = d;
        map<int, int> cost;
        for (arr ele:graph[i])
        {
            if (ele[0]==p) cost[c] +=ele[2];
            else cost[ele[1]] += ele[2];
        }
        int ava1 = -1;
        int ava2 = -1;
        int ava3 = -1;
        int avac1 = 0;
        int avac2 = 0;
        int avac3 = 0;
        for (int j = 0; j < m; j++)
        {
            if (cost[j]==0) 
            {
                if (ava1==-1) ava1 = j;
                else if (ava2==-1) ava2=j;
                else 
                {
                    ava3 = j;
                    break;
                }
            }
        }
        if (ava1==-1) avac1=1e18;
        if (ava2==-1) avac2=1e18;
        if (ava3==-1) avac3=1e18;
        for (arr ele:graph[i])
        {
            if (cost[ele[1]]<avac1)
            {
                ava3 = ava2;
                avac3 = avac2;
                ava2 = ava1;
                avac2 = avac1;
                avac1=cost[ele[1]];
                ava1=ele[1];
            }
            else if (cost[ele[1]]<avac2)
            {
                ava3 = ava2;
                avac3 = avac2;
                ava2 = ele[1];
                avac2=cost[ele[1]];
            }
            else if (cost[ele[1]]<avac3)
            {
                ava3=ele[1];
                avac3=cost[ele[1]];
            }
        }
        for (arr ele:graph[i])
        {
            if (ele[0]==p) continue;
            pq.push({d+cost[ele[1]]-ele[2], ele[1], ele[0], i});
            if (ava1!=-1) pq.push({d+ele[2]+avac1, ava1, ele[0], i});
            if (ava2!=-1) pq.push({d+ele[2]+avac2, ava2, ele[0], i});
            if (ava3!=-1) pq.push({d+ele[2]+avac3, ava3, ele[0], i});
        }
    }
    if (d1[n-1]==1e18) cout << -1;
    else cout << d1[n-1];
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:31:20: error: no matching function for call to 'std::vector<std::vector<long long int> >::assign(long long int&, int)'
   31 |     fc.assign(n, -1);
      |                    ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:749:47: note:   no known conversion for argument 2 from 'int' to 'const value_type&' {aka 'const std::vector<long long int>&'}
  749 |       assign(size_type __n, const value_type& __val)
      |                             ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  768 |  assign(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note:   template argument deduction/substitution failed:
Main.cpp:31:20: note:   deduced conflicting types for parameter '_InputIterator' ('long long int' and 'int')
   31 |     fc.assign(n, -1);
      |                    ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:794:7: note:   candidate expects 1 argument, 2 provided