답안 #394592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394592 2021-04-27T02:35:25 Z definitelynotmee 악어의 지하 도시 (IOI11_crocodile) C++
100 / 100
973 ms 81456 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<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:36: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]
   36 |         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 2636 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 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 2636 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 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 6 ms 3276 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 2636 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 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 6 ms 3276 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 648 ms 69716 KB Output is correct
17 Correct 128 ms 20544 KB Output is correct
18 Correct 179 ms 22140 KB Output is correct
19 Correct 973 ms 81456 KB Output is correct
20 Correct 317 ms 54980 KB Output is correct
21 Correct 53 ms 10104 KB Output is correct
22 Correct 374 ms 51808 KB Output is correct