답안 #717350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
717350 2023-04-01T21:20:09 Z vjudge1 Paths (RMI21_paths) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>;
vector<pair<int,int>>vct[1001];
int mp[1001][1001];
int n,in=1;
long long ans;
void slv(){
    deque<pair<int,int>>pq={{0,in}};
    vector<int>vis(n+1);
    int g=0;
    vis[in]=in;
    while(pq.size()){
        int a=pq.front().second
        long long b=pq.front().first;
        pq.pop_front();
        if(b>=g){
            g=b;
            in=a;
        }
        for(auto &i:vct[a]){
            if(!vis[i.first]){
                vis[i.first]=a;
                pq.push_back({b+mp[a][i.first],i.first});
            }
        }
    }
    int I=in;
    while(vis[I]!=I){
        ans+=mp[vis[I]][I];
        mp[vis[I]][I]=0;
        mp[I][vis[I]]=0;
        I=vis[I];
    }
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k;
    cin>>n>>k;
    for(int i=1;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        vct[a].push_back({b,c});
        vct[b].push_back({a,c});
    }
    int K=k;
    for(int w=1;w<=n;w++){
        ans=0;
        in=w;
        for(int j=1;j<=n;j++){
            for(auto &z:vct[j]){
                mp[j][z.first]=z.second;
            }
        }
        k=K;
        while(k--)slv();
        cout<<ans<<endl;
    }
}

Compilation message

Main.cpp: In function 'void slv()':
Main.cpp:20:9: error: expected ',' or ';' before 'long'
   20 |         long long b=pq.front().first;
      |         ^~~~
Main.cpp:22:12: error: 'b' was not declared in this scope
   22 |         if(b>=g){
      |            ^
Main.cpp:29:31: error: 'b' was not declared in this scope
   29 |                 pq.push_back({b+mp[a][i.first],i.first});
      |                               ^
Main.cpp:29:56: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   29 |                 pq.push_back({b+mp[a][i.first],i.first});
      |                                                        ^
In file included from /usr/include/c++/10/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:68,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_deque.h:1493:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::deque<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1493 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_deque.h:1493:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1493 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_deque.h:1508:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::deque<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1508 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_deque.h:1508:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1508 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~