답안 #16203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16203 2015-08-17T11:01:48 Z khsoo01 악어의 지하 도시 (IOI11_crocodile) C++
46 / 100
349 ms 128744 KB
#include<bits/stdc++.h>
#define ll long long
#define INF 987654321987654321ll
#include "crocodile.h"
using namespace std;
priority_queue<pair<ll,ll> >pq;
vector<ll>cg[100005],cv[100005];
ll n,m,k,p[100005],cval,cidx;
ll mn[100005][2];
bool vis[100005];

bool update(ll idx,ll val) {
    if(mn[idx][0]>val) {
        mn[idx][1]=mn[idx][0];
        mn[idx][0]=val;
        return true;
    }
    if(mn[idx][1]>val) {
        mn[idx][1]=val;
        return true;
    }
    return false;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    ll i; n=N; m=N; k=K;
    for(i=0;i<k;i++) {
        p[i]=P[i];
        pq.push({0,p[i]});
    }
    for(i=0;i<n;i++) {
        mn[i][0]=INF;
        mn[i][1]=INF;
    }
    for(i=0;i<m;i++) {
        cg[R[i][0]].push_back(R[i][1]);
        cv[R[i][0]].push_back(L[i]);
        cg[R[i][1]].push_back(R[i][0]);
        cv[R[i][1]].push_back(L[i]);
    }
    while(!pq.empty()) {
        cval=-pq.top().first;
        cidx=pq.top().second;
        pq.pop();
        if(vis[cidx])continue;
        vis[cidx]=true;
        for(i=0;i<cg[cidx].size();i++) {
            if(!vis[cg[cidx][i]] && update(cg[cidx][i],cv[cidx][i]+cval) && mn[cg[cidx][i]][1]!=INF) {
                pq.push({-mn[cg[cidx][i]][1],cg[cidx][i]});
            }
        }
    }
    return mn[0][1];
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 126236 KB Output is correct
2 Correct 0 ms 126236 KB Output is correct
3 Correct 0 ms 126236 KB Output is correct
4 Correct 0 ms 126236 KB Output is correct
5 Correct 0 ms 126236 KB Output is correct
6 Correct 2 ms 126236 KB Output is correct
7 Correct 0 ms 126236 KB Output is correct
8 Correct 2 ms 126236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 126236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 349 ms 128744 KB Output isn't correct
2 Halted 0 ms 0 KB -