답안 #1046452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046452 2024-08-06T14:59:37 Z oscar1f 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
243 ms 68292 KB
#include<bits/stdc++.h>
#include "crocodile.h"
using namespace std;

const int MAX_SOM=100*1000+5,INFINI=1000*1000*1000+5;
int nbSom,nbAre,nbExit;
int dist[MAX_SOM];
int meil[MAX_SOM][2];
vector<pair<int,int>> adja[MAX_SOM];
priority_queue<pair<int,int>> possi;

void ajout(int pos,int val) {
    if (val<meil[pos][1]) {
        meil[pos][1]=val;
        if (meil[pos][0]>meil[pos][1]) {
            swap(meil[pos][0],meil[pos][1]);
        }
        possi.push({-meil[pos][1],pos});
    }
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    nbSom=N;
    nbAre=M;
    nbExit=K;
    for (int i=0;i<nbSom;i++) {
        meil[i][0]=INFINI;
        meil[i][1]=INFINI;
        dist[i]=-1;
    }
    for (int i=0;i<nbAre;i++) {
        adja[R[i][0]].push_back({R[i][1],L[i]});
        adja[R[i][1]].push_back({R[i][0],L[i]});
    }
    for (int i=0;i<nbExit;i++) {
        possi.push({0,P[i]});
    }
    int distCour,pos;
    while (!possi.empty()) {
        distCour=-possi.top().first;
        pos=possi.top().second;
        possi.pop();
        if (dist[pos]==-1) {
            dist[pos]=distCour;
            for (auto i:adja[pos]) {
                ajout(i.first,distCour+i.second);
            }
        }
    }
    return dist[0];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6744 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6744 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 2 ms 7004 KB Output is correct
10 Correct 1 ms 6784 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 3 ms 7004 KB Output is correct
13 Correct 2 ms 7004 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6744 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 2 ms 7004 KB Output is correct
10 Correct 1 ms 6784 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 3 ms 7004 KB Output is correct
13 Correct 2 ms 7004 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 201 ms 62560 KB Output is correct
17 Correct 45 ms 19800 KB Output is correct
18 Correct 56 ms 21196 KB Output is correct
19 Correct 243 ms 68292 KB Output is correct
20 Correct 142 ms 54116 KB Output is correct
21 Correct 22 ms 12896 KB Output is correct
22 Correct 155 ms 51932 KB Output is correct