답안 #737819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
737819 2023-05-07T18:52:38 Z sandry24 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
605 ms 65376 KB
#include <bits/stdc++.h>
//#include "grader.h"
using namespace std;
 
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second

const int maxn = 100001, maxm = 1000001, INF = 2e9;
vector<vector<pi>> adj(maxn);
int dist[maxn][2], visited[maxn];
set<pi> s;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    for(int i = 0; i < M; i++){
        adj[R[i][0]].pb({R[i][1], L[i]});
        adj[R[i][1]].pb({R[i][0], L[i]});
    }
    for(int i = 0; i <= N; i++)
        dist[i][0] = dist[i][1] = INF;

    for(int i = 0; i < K; i++){
        dist[P[i]][0] = dist[P[i]][1] = 0;
        s.insert({0, P[i]});
    }

    while(!s.empty()){
        int a = s.begin()->second;
        s.erase(s.begin());
        if(visited[a])
            continue;
        visited[a] = 1;
        for(auto i : adj[a]){
            int b = i.f, w = i.s;
            if(visited[b])
                continue;
            if(dist[b][0] > dist[a][1] + w){
                dist[b][1] = dist[b][0];
                dist[b][0] = dist[a][1] + w;
                if(dist[b][1] != INF)
                    s.insert({dist[b][1], b});
            } else if(dist[b][1] > dist[a][1] + w){
                dist[b][1] = dist[a][1] + w;
                s.insert({dist[b][1], b});
            }
        }
    }
    return dist[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 3 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 3 ms 2684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 3 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 3 ms 2684 KB Output is correct
9 Correct 4 ms 2900 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 4 ms 2724 KB Output is correct
12 Correct 5 ms 3156 KB Output is correct
13 Correct 4 ms 3156 KB Output is correct
14 Correct 2 ms 2684 KB Output is correct
15 Correct 2 ms 2720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 3 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 3 ms 2684 KB Output is correct
9 Correct 4 ms 2900 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 4 ms 2724 KB Output is correct
12 Correct 5 ms 3156 KB Output is correct
13 Correct 4 ms 3156 KB Output is correct
14 Correct 2 ms 2684 KB Output is correct
15 Correct 2 ms 2720 KB Output is correct
16 Correct 435 ms 59536 KB Output is correct
17 Correct 71 ms 14028 KB Output is correct
18 Correct 86 ms 15536 KB Output is correct
19 Correct 605 ms 65376 KB Output is correct
20 Correct 252 ms 49584 KB Output is correct
21 Correct 35 ms 7712 KB Output is correct
22 Correct 292 ms 46160 KB Output is correct