Submission #253994

#TimeUsernameProblemLanguageResultExecution timeMemory
253994khangalSky Walking (IOI19_walk)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18
#define MIN -1e18
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,ans,mid,mn,mx,T,sum,h1,h2,e[1234567],b[1234567],c[1234567],d[1<<20],k,i,j,l,r,h,a[1234567],w,x,y,z;
bool used[1234567];
vector<int> v[1234567],vec,vv1,vv2;
string s1,s;
ll sz[1234567],par[1234567],tr[3234567],dist[123][123];
ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
vector<ll> adj[123][123];
ll search(ll id, ll val){
    return lw(v[id].begin(), v[id].end(), val) - v[id].begin();
}
ll djikstra(ll x1, ll x2, ll y1, ll y2){
    for(ll i = 0; i < 60; i++)
        for(ll j = 0; j < 60; j++)
            dist[i][j] = MAX;
    priority_queue<tuple<ll,ll,ll>> pq;
    dist[x1][x2] = 0;
    pq.push({0, x1, x2});
    while(!pq.empty()){
        tie(x,y,z) = pq.top();
        pq.pop();
        ll u1 = y, u2 = z;
        if(x != dist[u1][u2])
            continue;
        if(u1 == y1 && u2 == y2)
            break;
        for(auto edge : adj[u1][u2]){
            ll P = edge[0], Q = edge[1];
            if(dist[P][Q] > dist[u1][u2] + edge[2]){
                dist[P][Q] = dist[u1][u2] + edge[2];
                pq.push({dist[P][Q], P, Q});
            }
        }
    }
    return dist[y1][y2];
}
ll min_distance(vl X, vl H,vl L,vl R,vl Y,ll s,ll g){
    n = X.size();
    m = Y.size();
    for(ll i = 0; i < m; i++){
        for(ll j = L[i]; j <= R[i]; j++){
            if(H[j] >= Y[i])
                v[j].pb(Y[i]);
        }
    }
    for(ll i = 0; i < n; i++){
        v[i].pb(0);
        v[i].pb(H[i]);
        sort(v[i].begin(),v[i].end());
    }
    for(ll i = 0; i < n; i++){
        vl vec;
        set<ll> st;
        for(auto u:v[i])st.insert(u);
        for(auto u:st)vec.pb(u);
        v[i] = vec;
    }
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < cross[i].size() - 1; j++){
            adj[i][j].pb({i, j + 1, v[i][j + 1] - v[i][j]});
            adj[i][j + 1].pb({i, j, v[i][j + 1] - v[i][j]});
        }
    }
    for(ll i = 0; i < m; i++){
        ll tmp = -1;
        for(ll j = L[i]; j <= R[i]; j++){
            if(H[j] >= Y[i]){
                if(tmp == -1){
                    tmp = j;
                    continue;
                }
                ll j1 = search(j, Y[i]) , tmp1 = search(tmp, Y[i]);
                adj[j][j1].pb({tmp, tmp1, X[j] - X[tmp]});
                adj[tmp][tmp1].pb({j, j1, X[j] - X[tmp]});
                tmp = j;
            }
        }
    }
    ll res = djikstra(s,0,g,0);
    if(res==MAX)return -1;
    else return res;
}

Compilation message (stderr)

walk.cpp: In function 'll djikstra(ll, ll, ll, ll)':
walk.cpp:51:26: error: invalid types 'long long int[int]' for array subscript
             ll P = edge[0], Q = edge[1];
                          ^
walk.cpp:52:24: error: 'Q' was not declared in this scope
             if(dist[P][Q] > dist[u1][u2] + edge[2]){
                        ^
walk.cpp:52:50: error: invalid types 'long long int[int]' for array subscript
             if(dist[P][Q] > dist[u1][u2] + edge[2]){
                                                  ^
walk.cpp:53:51: error: invalid types 'long long int[int]' for array subscript
                 dist[P][Q] = dist[u1][u2] + edge[2];
                                                   ^
walk.cpp:54:43: error: no matching function for call to 'std::priority_queue<std::tuple<long long int, long long int, long long int> >::push(<brace-enclosed initializer list>)'
                 pq.push({dist[P][Q], P, Q});
                                           ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from walk.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:595:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::less<std::tuple<long long int, long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<long long int, long long int, long long int>]
       push(const value_type& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:595:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::tuple<long long int, long long int, long long int>&}'
/usr/include/c++/7/bits/stl_queue.h:603:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::less<std::tuple<long long int, long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<long long int, long long int, long long int>]
       push(value_type&& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:603:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<long long int, long long int, long long int> >::value_type&& {aka std::tuple<long long int, long long int, long long int>&&}'
walk.cpp: In function 'll min_distance(vl, vl, vl, vl, vl, ll, ll)':
walk.cpp:79:16: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'vl {aka std::vector<long long int>}')
         v[i] = vec;
                ^~~
In file included from /usr/include/c++/7/vector:69:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from walk.cpp:1:
/usr/include/c++/7/bits/vector.tcc:179:5: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/vector.tcc:179:5: note:   no known conversion for argument 1 from 'vl {aka std::vector<long long int>}' to 'const std::vector<int>&'
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from walk.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:461:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:461:7: note:   no known conversion for argument 1 from 'vl {aka std::vector<long long int>}' to 'std::vector<int>&&'
/usr/include/c++/7/bits/stl_vector.h:482:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(initializer_list<value_type> __l)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: note:   no known conversion for argument 1 from 'vl {aka std::vector<long long int>}' to 'std::initializer_list<int>'
walk.cpp:82:27: error: 'cross' was not declared in this scope
         for(ll j = 0; j < cross[i].size() - 1; j++){
                           ^~~~~
walk.cpp:82:27: note: suggested alternative: 'cosl'
         for(ll j = 0; j < cross[i].size() - 1; j++){
                           ^~~~~
                           cosl
walk.cpp:83:59: error: no matching function for call to 'std::vector<long long int>::push_back(<brace-enclosed initializer list>)'
             adj[i][j].pb({i, j + 1, v[i][j + 1] - v[i][j]});
                                                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from walk.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const long long int&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<long long int>::value_type&& {aka long long int&&}'
walk.cpp:84:59: error: no matching function for call to 'std::vector<long long int>::push_back(<brace-enclosed initializer list>)'
             adj[i][j + 1].pb({i, j, v[i][j + 1] - v[i][j]});
                                                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from walk.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const long long int&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<long long int>::value_type&& {aka long long int&&}'
walk.cpp:96:57: error: no matching function for call to 'std::vector<long long int>::push_back(<brace-enclosed initializer list>)'
                 adj[j][j1].pb({tmp, tmp1, X[j] - X[tmp]});
                                                         ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from walk.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const long long int&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<long long int>::value_type&& {aka long long int&&}'
walk.cpp:97:57: error: no matching function for call to 'std::vector<long long int>::push_back(<brace-enclosed initializer list>)'
                 adj[tmp][tmp1].pb({j, j1, X[j] - X[tmp]});
                                                         ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from walk.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const long long int&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<long long int>::value_type&& {aka long long int&&}'