제출 #1161709

#제출 시각아이디문제언어결과실행 시간메모리
1161709tw20000807Robot (JOI21_ho_t4)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")
#define all(v) v.begin(), v.end()
#define SZ(x) (int)x.size()
#define pii pair<int, int>
#define X first
#define Y second

using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;//    998244353;
const int llmx = 1e18;


void sol(){
    int n, m;
    cin >> n >> m;
    vector< vector< array<int, 3> > > g(n + 1);
    vector< vector< pii > > cnt(n + 1);

    vector< int > dis(2 * m + n + 1, llmx);
    vector< vector< pii > > num(n + 1);
    vector< int > base(n + 1);
    while(m--){
        int a, b, c, p;
        cin >> a >> b >> c >> p;
        cnt[a].push_back({c, 0});
        cnt[b].push_back({c, 0});

        num[a].push_back({p, c});
        num[b].push_back({p, c});

        g[a].push_back({b, c, p});
        g[b].push_back({a, c, p});
    }
    for(int i = 1; i <= n; ++i){
        sort(all(cnt[i]));
        cnt[i].resize(unique(all(cnt[i])) - cnt[i].begin());
        num[i].push_back({0, 0});
        sort(all(num[i]));
        num[i].resize(unique(all(num[i])) - num[i].begin());
        base[i] = base[i - 1] + SZ(num[i - 1]);
        for(auto &[nxt, c, p] : g[i]){
            auto it = lower_bound(all(cnt[i]), pii(c, 0));
            it->Y += p;
        }
    }
    auto get = [&](int id, int p, int c) -> int {
        return base[id] + lower_bound(all(num[id]), pii(p, c)) - num[id].begin();
    };

    deque< int > pq;

    dis[get(1, 0, 0)] = 0;
    pq.push_back({0, 1, 0, 0, get(1, 0, 0)});
    while(!pq.empty()){
        auto [D, cur, cost, col, nid] = pq.front(); pq.pop_front();
        if(dis[nid] != D) continue;
        if(cur == n){
            cout << D << "\n";
            return;
        }
        for(auto &[nxt, c, p] : g[cur]){
            int id1 = get(nxt, p, c);
            int id2 = get(nxt, 0, 0);
            int al = lower_bound(all(cnt[cur]), pii(c, 0))->Y;

            if(dis[id1] > D + p){
                dis[id1] = D + p;
                pq.push_back({dis[id1], nxt, p, c, id1});
            }
            if(dis[id2] > D + max(0LL, al - p - (c == col ? cost : 0))){
                dis[id2] = D + max(0LL, al - p - (c == col ? cost : 0));
                pq.push_back({dis[id2], nxt, 0, 0, id2});
            }
        }
    }
    cout << "-1\n";
}
/*
4 6
1 4 4 4
3 4 1 3
1 3 4 4
2 4 3 1
2 3 3 2
1 2 4 2

// 3

5 2
1 4 1 2
3 5 1 4
// -1


5 7
2 3 7 1
1 4 5 1
4 5 3 1
3 4 7 1
2 4 3 1
3 5 6 1
1 2 5 1
// 1

13 21
7 10 4 4
3 6 4 7
8 10 4 5
3 9 2 5
1 4 4 5
2 6 4 2
3 11 2 2
3 8 16 2
8 11 16 1
6 10 4 14
6 8 16 6
9 12 16 5
5 13 4 6
1 12 4 7
2 4 4 18
2 9 4 10
2 12 4 6
10 13 4 28
5 7 2 5
5 11 2 16
7 13 4 20

// 7


*/
signed main(){
    ios::sync_with_stdio(0), cin.tie(0), cerr.tie(0);
    int t = 1; //cin >> t;
    while(t--) sol();
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void sol()':
Main.cpp:56:17: error: no matching function for call to 'std::deque<long long int>::push_back(<brace-enclosed initializer list>)'
   56 |     pq.push_back({0, 1, 0, 0, get(1, 0, 0)});
      |     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:68,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_deque.h:1496:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::deque<_Tp, _Alloc>::value_type = long long int]'
 1496 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_deque.h:1496:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const long long int&'}
 1496 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_deque.h:1511:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::deque<_Tp, _Alloc>::value_type = long long int]'
 1511 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_deque.h:1511:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<long long int>::value_type&&' {aka 'long long int&&'}
 1511 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Main.cpp:58:14: error: cannot decompose non-array non-class type 'long long int'
   58 |         auto [D, cur, cost, col, nid] = pq.front(); pq.pop_front();
      |              ^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:71:29: error: no matching function for call to 'std::deque<long long int>::push_back(<brace-enclosed initializer list>)'
   71 |                 pq.push_back({dis[id1], nxt, p, c, id1});
      |                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:68,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_deque.h:1496:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::deque<_Tp, _Alloc>::value_type = long long int]'
 1496 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_deque.h:1496:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const long long int&'}
 1496 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_deque.h:1511:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::deque<_Tp, _Alloc>::value_type = long long int]'
 1511 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_deque.h:1511:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<long long int>::value_type&&' {aka 'long long int&&'}
 1511 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Main.cpp:75:29: error: no matching function for call to 'std::deque<long long int>::push_back(<brace-enclosed initializer list>)'
   75 |                 pq.push_back({dis[id2], nxt, 0, 0, id2});
      |                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:68,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_deque.h:1496:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::deque<_Tp, _Alloc>::value_type = long long int]'
 1496 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_deque.h:1496:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const long long int&'}
 1496 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_deque.h:1511:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::deque<_Tp, _Alloc>::value_type = long long int]'
 1511 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_deque.h:1511:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<long long int>::value_type&&' {aka 'long long int&&'}
 1511 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~