답안 #731360

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
731360 2023-04-27T11:03:45 Z lucri 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
489 ms 61320 KB
#include "crocodile.h"
#include <bits/stdc++.h>
int time1[100010],time2[100010],n,m;
std::vector<std::vector<std::pair<int,int>>>a;
std::priority_queue<std::pair<int,int>>q;
bool viz[100010];
void lee()
{
    while(!q.empty())
    {
        int val=-q.top().first;
        int nod=q.top().second;
        q.pop();
        if(viz[nod]==true)
            continue;
        viz[nod]=true;
        for(auto x:a[nod])
        {
            if(time1[x.first]==0||time1[x.first]>val+x.second)
            {
                time2[x.first]=time1[x.first];
                time1[x.first]=val+x.second;
                if(time2[x.first]!=0)
                    q.push({-time2[x.first],x.first});
            }
            else if(time2[x.first]==0||time2[x.first]>val+x.second)
            {
                time2[x.first]=val+x.second;
                q.push({-time2[x.first],x.first});
            }
        }
    }
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n=N;
    m=M;
    a.resize(n+5);
    for(int i=0;i<m;++i)
    {
        a[R[i][0]].push_back({R[i][1],L[i]});
        a[R[i][1]].push_back({R[i][0],L[i]});
    }
    for(int i=0;i<K;++i)
    {
        time1[P[i]]=time2[P[i]]=1;
        q.push({-1,P[i]});
    }
    lee();
    return time2[0]-1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 4 ms 724 KB Output is correct
13 Correct 3 ms 852 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 4 ms 724 KB Output is correct
13 Correct 3 ms 852 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 392 ms 55872 KB Output is correct
17 Correct 74 ms 13800 KB Output is correct
18 Correct 115 ms 15264 KB Output is correct
19 Correct 489 ms 61320 KB Output is correct
20 Correct 262 ms 47072 KB Output is correct
21 Correct 33 ms 6072 KB Output is correct
22 Correct 275 ms 44380 KB Output is correct