Submission #531008

# Submission time Handle Problem Language Result Execution time Memory
531008 2022-02-27T10:17:26 Z gsfdgsdfg Crocodile's Underground City (IOI11_crocodile) C++11
0 / 100
2 ms 2636 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int MAX_N(100005);
vector<pair<int, int> > G[MAX_N + 5];
ll distF[MAX_N + 5], distS[MAX_N + 5];
bool viz[MAX_N + 5];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    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]});
    for(int i = 0; i < N; ++i)
        distF[i] = 1e9 + 5, distS[i] = 1e9 + 5;
    priority_queue<pair<ll, int>, vector<pair<ll, int> > , greater<pair<ll, int> > > q;
    for(int i = 0; i < K; ++i)
    {
        distF[P[i]] = distS[P[i]] = 0;
        q.push({0, P[i]});
    }
    while(!q.empty())
    {
        int nd = q.top().second;
        ll dist = q.top().first;
        q.pop();
        for(auto it: G[nd])
            if(distF[it.first] == 1e9 + 5)
            {
                distF[it.first] = dist + it.second;
                q.push({distS[it.first], it.first});
            }
            else if(distS[it.first] == 1e9 + 5 || dist + it.second < distS[it.first]){
                distS[it.first] = dist + it.second;
                if(distF[it.first] > distS[it.first])
                    swap(distF[it.first], distS[it.first]);
                q.push({distS[it.first], it.first});
            }
    }
    return distS[0];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -