답안 #1102602

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102602 2024-10-18T12:12:18 Z asli_bg 악어의 지하 도시 (IOI11_crocodile) C++11
컴파일 오류
0 ms 0 KB
#pragma GCC optimize("O3,unroll-loops")
 
#include<bits/stdc++.h>
using namespace std;

#include "crocodile.h"
 
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define FOR(i,a) for(int i=0;i<(a);i++)
#define FORE(i,a,b) for(int i=(a);i<(b);i++)
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vii;
 
#define cont(x) for(auto el:x) {cout<<el<<' ';} cout<<endl;
#define endl '\n'
#define contp(x) for(auto el:x) {cout<<el.fi<<'-'<<el.se<<' ';} cout<<endl;
#define pb push_back
 
#define sp <<' '<<
 
#define DEBUG(x) {cout<<(#x) sp x<<endl;}
 
const int MAXN=1e5+5;
const int INF=1e9;

int n,m,k;
vii adj[MAXN];
vi ex;
//her node için min 3 yolu tut, nereden geldiğiyle birlikte
multiset<pii> yol[MAXN];
bool vis[MAXN];
bool cikis[MAXN];

void bfs(){
    multiset<pii> s;
    for(auto el:ex){
        s.insert({0,el});
        vis[el]=true;
        yol[el].insert({0,el});
        yol[el].insert({0,el});
        yol[el].insert({0,el});
    }

    while(!s.empty()){
        auto el=*s.begin();
        s.erase(s.find(*s.begin()));

        int dd=el.fi;
        int nd=el.se;

        vis[nd]=true;

        for(auto temp:adj[nd]){
            int kom=temp.fi;
            int cost=temp.se;

            if(cikis[kom]) continue;
            s.erase(s.find({yol[kom].begin()->fi,kom}));
            yol[kom].insert({dd+cost,nd});
            //her komsu node için bir tane min degerini sadece tut
            if(yol[kom].size()>3){
                //sonuncu elemanı sil
                yol[kom].erase(yol[kom].find(*yol[kom].rbegin()));
            }

            if(vis[kom]) continue;
            s.insert(s.find({yol[kom].begin()->fi,kom}));
        }
    }
}

int cev;

void dfs(int nd,int ata,int dd){
    vis[nd]=true;

    //min path
    auto it=yol[nd].begin();
    int mn=it->se;
    if(mn==ata){
        it++;
        mn=it->se;
    }

    if(mn==nd){
        cev=min(dd,cev);
        return;
    }

    for(auto el:adj[nd]){
        int kom=el.fi;
        int cost=el.se;
        if(kom==ata or kom==mn) continue;
        if(vis[kom]) continue;
        dfs(kom,nd,dd+cost);
    }
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    n=N;
    m=M;
    k=K;
    FOR(i,m){
        int bir=R[i][0];
        int iki=R[i][1];
        bir++;iki++;
        adj[bir].pb({iki,L[i]});
        adj[iki].pb({bir,L[i]});
    }

    FOR(i,k){
        P[i]++;
        cikis[P[i]]=true;
        ex.pb(P[i]);
    }

    bfs();
    cev=INF;
    
    memset(vis,0,sizeof vis);
    dfs(1,0,0);

    return cev;
}

Compilation message

crocodile.cpp: In function 'void bfs()':
crocodile.cpp:72:56: error: no matching function for call to 'std::multiset<std::pair<int, int> >::insert(std::multiset<std::pair<int, int> >::iterator)'
   72 |             s.insert(s.find({yol[kom].begin()->fi,kom}));
      |                                                        ^
In file included from /usr/include/c++/10/set:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from crocodile.cpp:3:
/usr/include/c++/10/bits/stl_multiset.h:502:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]'
  502 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_multiset.h:502:32: note:   no known conversion for argument 1 from 'std::multiset<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} to 'const value_type&' {aka 'const std::pair<int, int>&'}
  502 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_multiset.h:507:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]'
  507 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_multiset.h:507:27: note:   no known conversion for argument 1 from 'std::multiset<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} to 'std::multiset<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  507 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_multiset.h:532:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]'
  532 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_multiset.h:532:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_multiset.h:537:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, std::multiset<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]'
  537 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_multiset.h:537:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_multiset.h:551:2: note: candidate: 'template<class _InputIterator> void std::multiset<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  551 |  insert(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_multiset.h:551:2: note:   template argument deduction/substitution failed:
crocodile.cpp:72:56: note:   candidate expects 2 arguments, 1 provided
   72 |             s.insert(s.find({yol[kom].begin()->fi,kom}));
      |                                                        ^
In file included from /usr/include/c++/10/set:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from crocodile.cpp:3:
/usr/include/c++/10/bits/stl_multiset.h:563:7: note: candidate: 'void std::multiset<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  563 |       insert(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_multiset.h:563:43: note:   no known conversion for argument 1 from 'std::multiset<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} to 'std::initializer_list<std::pair<int, int> >'
  563 |       insert(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~