답안 #394586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394586 2021-04-27T01:46:25 Z definitelynotmee 악어의 지하 도시 (IOI11_crocodile) C++
100 / 100
911 ms 86224 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]});
    }
    
    set<pll> s;
    vector<pll> dist(n,{INFL,INFL});
    vector<multiset<ll>> possd (n);
    vector<bool> passq(n,0);
    for(int i = 0; i < k; i++)
        s.insert({0,p[i]}), dist[p[i]] = {0,0};
    
    while(!s.empty()){
        ll cur = s.begin()->second;
        s.erase(s.begin());
        if(passq[cur] == 1)
            continue;
        passq[cur] = 1;
        for(int i = 0; i < grafo[cur].size(); i++){
            
            ll viz = grafo[cur][i].ff;
            ll vizp = grafo[cur][i].ss;
            if(vizp + dist[cur].ff < dist[viz].ss){
                dist[viz].ff = dist[viz].ss;
                dist[viz].ss = vizp + dist[cur].ff;
                s.insert({dist[viz].ff, viz});
            } else if(vizp + dist[cur].ff < dist[viz].ff){
                dist[viz].ff = vizp + dist[cur].ff;
                s.insert({dist[viz].ff, viz});
            }
        }
    }
    return dist[0].ff;
}

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 Correct 3 ms 2764 KB Output is correct
5 Correct 3 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 4 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 3 ms 2764 KB Output is correct
5 Correct 3 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 4 ms 2764 KB Output is correct
9 Correct 4 ms 3020 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 5 ms 3252 KB Output is correct
13 Correct 5 ms 3276 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 3 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 3 ms 2764 KB Output is correct
5 Correct 3 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 4 ms 2764 KB Output is correct
9 Correct 4 ms 3020 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 5 ms 3252 KB Output is correct
13 Correct 5 ms 3276 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 3 ms 2764 KB Output is correct
16 Correct 618 ms 71596 KB Output is correct
17 Correct 141 ms 25348 KB Output is correct
18 Correct 174 ms 26828 KB Output is correct
19 Correct 911 ms 86224 KB Output is correct
20 Correct 336 ms 55096 KB Output is correct
21 Correct 54 ms 11588 KB Output is correct
22 Correct 364 ms 53316 KB Output is correct