답안 #1003219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003219 2024-06-20T07:55:45 Z LilPluton 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
283 ms 63404 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define OPT         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define intt        long long
#define ll          long long
#define pb          push_back
#define ff          first
#define arr         array
#define vll         vector<int>
#define rep(i,j,k)  for(int i = j; i <= k; ++i)
#define all(a)      a.begin(),a.end()
#define pii         pair<int,int>
#define endll       '\n'
using namespace std;
const int INF = 1e9;
const int N = 1e5 + 5;




int travel_plan(int n, int m, int r[][2], int L[], int k, int p[])
{
    vector<vector<arr<int,2>>>g(N);
    for(int i = 0; i < m; i ++){
        g[r[i][0]].push_back({r[i][1], L[i]});
        g[r[i][1]].push_back({r[i][0], L[i]});
    }
    arr<int,2>dist[n];
    bool vis[n];
    for(int i = 0; i < n; ++i)
        dist[i] = {INF,INF}, vis[i] = false;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>>q;
    for(int i = 0; i < k; ++i)
    {
        q.push({0, p[i]});
        dist[p[i]] = {0 , 0};
    }
    while(!q.empty())
    {
        int v = q.top().second;
        q.pop();
        if(vis[v])
            continue;
        vis[v] = true;
        for(auto i : g[v])
        {
            int u = i[0];
            int w = i[1];
            if(dist[u][0] > dist[v][1] + w)
            {
                dist[u][1] = dist[u][0];
				dist[u][0] = dist[v][1] + w ;
				q.push({dist[u][1], u});
            }
            else if(dist[u][1] > dist[v][1] + w)
            {
                dist[u][1] = dist[v][1] + w;
				q.push({dist[u][1], u});
            }
        }
    }
    return dist[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2904 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2904 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2756 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 3 ms 3164 KB Output is correct
13 Correct 3 ms 3164 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2904 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2756 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 3 ms 3164 KB Output is correct
13 Correct 3 ms 3164 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2908 KB Output is correct
16 Correct 241 ms 58312 KB Output is correct
17 Correct 55 ms 15056 KB Output is correct
18 Correct 65 ms 16420 KB Output is correct
19 Correct 283 ms 63404 KB Output is correct
20 Correct 161 ms 49716 KB Output is correct
21 Correct 25 ms 8152 KB Output is correct
22 Correct 185 ms 46508 KB Output is correct