Submission #1202952

#TimeUsernameProblemLanguageResultExecution timeMemory
1202952VahanAbrahamCyberland (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <cmath>
#include <vector>
#include <iomanip>
#include <random>
#include <chrono>
#include <bitset>
#include <cassert>
using namespace std;

#define ll long long
#define fr first
#define sc second
#define pb push_back
#define US freopen(".in", "r", stdin); freopen(".out", "w", stdout);

ll gcd(ll a, ll b)
{
    if (a == 0 || b == 0) {
        return  max(a, b);
    }
    if (a <= b) {
        return gcd(a, b % a);
    }
    else {
        return gcd(a % b, b);
    }
}
ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

const int N = 100005;
const ll oo = 1000000000000000, MOD = 1000000007;


vector<int> g[N];
double dist[N][30];

double solve(int n,int m,int k,int h,vector<int> vec1,vector<int> vec2,vector<int> vec3,vector<int> a) {
    for(int i=0;i<m;++i){
        g[vec1[i]].pb({vec2[i],vec3[i]});
        g[vec2[i]].pb({vec1[i],vec3[i]});
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<=k;++j){
            dist[i][j]=oo;
        }
    }
    dist[0][0]=0;
    set<pair<double,pair<int,int>>> st;
    st.push({dist[0][0],{0,0}});
    while(st.size>0)){
        auto it=st.begin();
        pair<double,pair<int,int>> p=(*it);
        st.erase(it);
        int k1=p.sc.fr;
        int u=p.sc.sc;
        double val=p.fr;
        if(dist[u][k1]!=val){
           continue;
        }
        double val2=val/2.0;
        for(pair<int,int> num : g[u]){
            int h =num.fr;
            int w=num.sc;
            if(k1<k){
                if(a[u]==0){
                    if(dist[h][k1+1]>w){
                        dist[h][k1+1]=w;
                        st.insert({dist[h][k1+1],{k1+1,h}});
                    }
                    if(dist[h][k1]>val+w){
                        dist[h][k1]=val+w;
                        st.insert({dist[h][k1],{k1,h}});
                    }
                }
                else{
                    if(a[u]==2){
                        if(dist[h][k1+1]>val2+w){
                           dist[h][k1+1]=val2+w;
                           st.insert({dist[h][k1+1],{k1+1,h}});
                        }
                        if(dist[h][k1]>val+w){
                           dist[h][k1]=val+w;
                           st.insert({dist[h][k1],{k1,h}});
                        }
                    }
                    else{
                        if(dist[h][k1]>val+w){
                           dist[h][k1]=val+w;
                           st.insert({dist[h][k1],{k1,h}});
                        }
                    }
                }
            }
            else{
                if(a[u]==0){
                    if(dist[h][k1]>val+w){
                        dist[h][k1]=val+w;
                        st.insert({dist[h][k1],{k1,h}});
                    }
                }
                else{
                    if(a[u]==2){
                        if(dist[h][k1]>val+w){
                           dist[h][k1]=val+w;
                           st.insert({dist[h][k1],{k1,h}});
                        }
                    }
                    else{
                        if(dist[h][k1]>val+w){
                           dist[h][k1]=val+w;
                           st.insert({dist[h][k1],{k1,h}});
                        }
                    }
                }
            }
        }
    }
    double mn=oo;
    for(int i=0;i<=k;++i){
        mn=min(mn,dist[h][i]);
    }
    if(mn==oo){
        return -1;
    }
    return mn;
}


//https://oj.uz/problem/view/APIO23_cyberland
/*int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //US
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
}*/

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:56:22: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   56 |         g[vec1[i]].pb({vec2[i],vec3[i]});
      |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from cyberland.cpp:4:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
cyberland.cpp:57:22: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   57 |         g[vec2[i]].pb({vec1[i],vec3[i]});
      |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from cyberland.cpp:4:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
cyberland.cpp:66:8: error: 'class std::set<std::pair<double, std::pair<int, int> > >' has no member named 'push'
   66 |     st.push({dist[0][0],{0,0}});
      |        ^~~~
cyberland.cpp:67:14: error: invalid use of member function 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::size() const [with _Key = std::pair<double, std::pair<int, int> >; _Compare = std::less<std::pair<double, std::pair<int, int> > >; _Alloc = std::allocator<std::pair<double, std::pair<int, int> > >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
   67 |     while(st.size>0)){
      |           ~~~^~~~
      |                  ()
cyberland.cpp:67:21: error: expected primary-expression before ')' token
   67 |     while(st.size>0)){
      |                     ^