답안 #345808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
345808 2021-01-08T05:41:34 Z daniel920712 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1574 ms 118160 KB
#include "crocodile.h"
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
bool is[100005];
long long small[5][100005];
vector < pair < long long , long long > > Next[100005];
priority_queue < pair < long long , pair < long long , long long > > , vector < pair < long long , pair < long long , long long > > > , greater < pair < long long , pair < long long , long long > > > > dij;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    int i;
    long long a,b,c;
    for(i=0;i<M;i++)
    {
        Next[R[i][0]].push_back(make_pair((long long) R[i][1],(long long) L[i]));
        Next[R[i][1]].push_back(make_pair((long long) R[i][0],(long long) L[i]));
    }
    for(i=0;i<N;i++)
    {
        small[0][i]=-1;
        small[1][i]=-1;
    }
    for(i=0;i<K;i++)
    {
        is[P[i]]=1;
        dij.push(make_pair(0,make_pair(P[i],-1)));
        small[0][P[i]]=0;
        small[1][P[i]]=0;

    }
    while(!dij.empty())
    {
        a=dij.top().first;
        b=dij.top().second.first;
        c=dij.top().second.second;
        dij.pop();
        if(is[b]&&small[0][b]==0)
        {
            small[0][b]=-2;
            small[1][b]=-2;
            for(auto i:Next[b])
            {
                dij.push(make_pair(i.second+a,make_pair(i.first,b)));
            }
        }
        else if(small[0][b]==-1) small[0][b]=a;
        else if(small[1][b]==-1)
        {
            small[1][b]=a;
            for(auto i:Next[b])
            {
                dij.push(make_pair(i.second+a,make_pair(i.first,b)));
            }
        }
        else continue;
    }

    return small[1][0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:15:19: warning: variable 'c' set but not used [-Wunused-but-set-variable]
   15 |     long long a,b,c;
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2796 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 4 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2796 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 4 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 6 ms 3504 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 3 ms 3052 KB Output is correct
12 Correct 9 ms 4204 KB Output is correct
13 Correct 9 ms 4336 KB Output is correct
14 Correct 2 ms 2796 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2796 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 4 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 6 ms 3504 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 3 ms 3052 KB Output is correct
12 Correct 9 ms 4204 KB Output is correct
13 Correct 9 ms 4336 KB Output is correct
14 Correct 2 ms 2796 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
16 Correct 1443 ms 114340 KB Output is correct
17 Correct 102 ms 14572 KB Output is correct
18 Correct 145 ms 16748 KB Output is correct
19 Correct 1574 ms 118160 KB Output is correct
20 Correct 910 ms 104444 KB Output is correct
21 Correct 55 ms 8428 KB Output is correct
22 Correct 690 ms 51540 KB Output is correct