답안 #308831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308831 2020-10-02T04:37:55 Z juggernaut 악어의 지하 도시 (IOI11_crocodile) C++14
89 / 100
948 ms 48760 KB
#include "crocodile.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
vector <pair <int, int > > g[100002];
int inf =1e9+7;
pair <int, int> a[100001];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for(int i = 0; i <= N; i++){
        a[i].first=inf;
        a[i].second=inf;
    }
 
    multiset <pair <int, int> > st;
    multiset <pair <int, int> > ::iterator it;
 
    for(int i  = 0 ; i < M ;i++){
        g[R[i][0]].push_back(make_pair (R[i][1], L[i]) );
        g[R[i][1]].push_back( make_pair (R[i][0], L[i]));
    }
    for(int i = 0; i < K; i++){
 
 
        st.insert(make_pair(0,P[i]));
        a[P[i]].first=0;
        a[P[i]].second=0;
 
    }
    while(!st.empty()){
         it  = st.begin();
        int len = it->first;
        int v = it -> second;
        st.erase(it);
 
         if( len > a[v].second)
            continue;
        for(int i= 0 ; i< g[v].size() ; i++ ){
            int to = g[v][i].first;
            int dis = g[v][i].second;
            if(a[to].second > len + dis){
 
                a[to].second = len + dis;
                if(a[to].first > a[to].second)
                    swap(a[to].first, a[to].second);
                if(a[to].second < inf)
                st.insert(make_pair( a[to].second, to));
            }
        }
 
    }
 
    return a[0].second;
}
/*
 
5 4 3
0 1 2
0 2 3
3 2 1
2 4 4
1 3 4
*/
 

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:38:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int i= 0 ; i< g[v].size() ; i++ ){
      |                        ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 4 ms 2944 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 3 ms 2816 KB Output is correct
12 Correct 6 ms 3072 KB Output is correct
13 Correct 5 ms 3072 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 4 ms 2944 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 3 ms 2816 KB Output is correct
12 Correct 6 ms 3072 KB Output is correct
13 Correct 5 ms 3072 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 3 ms 2816 KB Output is correct
16 Correct 662 ms 43276 KB Output is correct
17 Correct 95 ms 10488 KB Output is correct
18 Correct 125 ms 11896 KB Output is correct
19 Correct 948 ms 48760 KB Output is correct
20 Correct 330 ms 36600 KB Output is correct
21 Correct 46 ms 6268 KB Output is correct
22 Incorrect 387 ms 31952 KB Output isn't correct