답안 #394580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394580 2021-04-27T01:05:58 Z definitelynotmee 악어의 지하 도시 (IOI11_crocodile) C++
0 / 100
3 ms 2764 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const int MAXN = 100001;

vector<pll> grafo[MAXN];

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
    
    for(int i = 0; i < m; i++){
        grafo[r[i][0]].push_back({r[i][1], l[i]});
        grafo[r[i][1]].push_back({r[i][0], l[i]});
    }
    
    multiset<pll> s;
    vector<ll> dist(n,INFL);
    vector<set<ll>> possd (n);
    for(int i = 0; i < n; i++)
        s.insert({INFL,i});
    for(int i = 0; i < k; i++)
        s.erase({INFL,p[i]}),s.insert({0,p[i]}), dist[p[i]] = 0;
    
    while(!s.empty()){
        ll cur = s.begin()->second;
        s.erase(s.begin());
        if(dist[cur] >= INFL)
            break;
        for(int i = 0; i < grafo[cur].size(); i++){
            ll viz = grafo[cur][i].ff;
            ll vizp = grafo[cur][i].ss;
            possd[viz].insert((ll)vizp + dist[cur]);
            if(possd[viz].size()>1 && dist[viz] > *(++possd[viz].begin())){
                s.erase({dist[viz],viz});
                dist[viz] = *(++possd[viz].begin());
                s.insert({dist[viz],viz});
            }
        }
    }
    return dist[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int i = 0; i < grafo[cur].size(); i++){
      |                        ~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 3 ms 2764 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 3 ms 2764 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 3 ms 2764 KB Output isn't correct
5 Halted 0 ms 0 KB -