답안 #787128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787128 2023-07-18T20:54:27 Z Sam_a17 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
436 ms 145288 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
 
#define ff first
#define ss second
 
ll ttt;
const ll INF=1e16;
const ll MOD=1e9+7;
const ll N= 3e6 + 10;
ll n,m,k;
vector<pair<ll,ll>>g[N];
bool vis[N];
 
int travel_plan(int NN, int MM, int R[][2], int L[], int KK, int P[]){
    n=NN;
    m=MM;
    k=KK;
    for(ll i=0;i<m;i++){
        // cout<<R[i][0]<<" "<<R[i][1]<<endl;
        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]));
    }
    priority_queue<pii,vector<pii>,greater<pii>>q;
    vector<ll>mn(n+1,INF),smn(n+1,INF);
    // cout<<mn[0]<<" "<<smn[0]<<endl;
    for(ll i=0;i<k;i++){
        q.push(make_pair(0,P[i]));
        mn[P[i]]=smn[P[i]]=0;
    }
    while(!q.empty()){
        ll v=q.top().ss;
        ll w=q.top().ff;
        q.pop();
        if(vis[v]) continue;
        vis[v] = true;
        // cout<<v<<" "<<w<<endl;
        // cout<<mn[v]<<" "<<smn[v]<<endl<<endl;
        if(smn[v]==w){
            for(pii x:g[v]){
                ll to=x.ff;
                ll dist=x.ss;
                // cout<<v<<" "<<to<<" "<<dist<<endl;
                // cout<<mn[to]<<" "<<smn[v]<<endl;
                // cout<<endl;
                if(mn[to]>smn[v]+dist){
                    smn[to]=mn[to];
                    mn[to]=smn[v]+dist;
                    q.push(make_pair(smn[to],to));
                }
                else if(smn[to]>smn[v]+dist){
                    smn[to]=smn[v]+dist;
                    q.push(make_pair(smn[to],to));
                }
            }
        }
    }
    return smn[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 70748 KB Output is correct
2 Correct 29 ms 70784 KB Output is correct
3 Correct 35 ms 70728 KB Output is correct
4 Correct 30 ms 70772 KB Output is correct
5 Correct 30 ms 70796 KB Output is correct
6 Correct 29 ms 70736 KB Output is correct
7 Correct 30 ms 70816 KB Output is correct
8 Correct 30 ms 70860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 70748 KB Output is correct
2 Correct 29 ms 70784 KB Output is correct
3 Correct 35 ms 70728 KB Output is correct
4 Correct 30 ms 70772 KB Output is correct
5 Correct 30 ms 70796 KB Output is correct
6 Correct 29 ms 70736 KB Output is correct
7 Correct 30 ms 70816 KB Output is correct
8 Correct 30 ms 70860 KB Output is correct
9 Correct 30 ms 71076 KB Output is correct
10 Correct 30 ms 70804 KB Output is correct
11 Correct 30 ms 70868 KB Output is correct
12 Correct 32 ms 71412 KB Output is correct
13 Correct 32 ms 71508 KB Output is correct
14 Correct 30 ms 70816 KB Output is correct
15 Correct 31 ms 70868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 70748 KB Output is correct
2 Correct 29 ms 70784 KB Output is correct
3 Correct 35 ms 70728 KB Output is correct
4 Correct 30 ms 70772 KB Output is correct
5 Correct 30 ms 70796 KB Output is correct
6 Correct 29 ms 70736 KB Output is correct
7 Correct 30 ms 70816 KB Output is correct
8 Correct 30 ms 70860 KB Output is correct
9 Correct 30 ms 71076 KB Output is correct
10 Correct 30 ms 70804 KB Output is correct
11 Correct 30 ms 70868 KB Output is correct
12 Correct 32 ms 71412 KB Output is correct
13 Correct 32 ms 71508 KB Output is correct
14 Correct 30 ms 70816 KB Output is correct
15 Correct 31 ms 70868 KB Output is correct
16 Correct 340 ms 136952 KB Output is correct
17 Correct 98 ms 84772 KB Output is correct
18 Correct 115 ms 87072 KB Output is correct
19 Correct 436 ms 145288 KB Output is correct
20 Correct 250 ms 123136 KB Output is correct
21 Correct 66 ms 77128 KB Output is correct
22 Correct 268 ms 118556 KB Output is correct