Submission #1056425

# Submission time Handle Problem Language Result Execution time Memory
1056425 2024-08-13T09:22:39 Z alexdd Cyberland (APIO23_cyberland) C++17
15 / 100
1675 ms 56640 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
const long long INF = 1e18;
const int MAXK = 30;
vector<pair<int,int>> con[100005];
vector<int> tip;
ld dist[MAXK+1][100005];
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
    K = min(K, MAXK);
    for(int i=0;i<N;i++)
    {
        con[i].clear();
    }
    tip = arr;
    for(int i=0;i<M;i++)
    {
        con[x[i]].push_back({y[i],c[i]});
        con[y[i]].push_back({x[i],c[i]});
    }
    for(int nr=0;nr<=K;nr++)
        for(int i=0;i<N;i++)
            dist[nr][i]=INF;
    priority_queue<pair<ld,pair<int,int>>> pq;
    dist[0][0]=0;
    pq.push({0,{0,0}});
    while(!pq.empty())
    {
        ld cdist = -pq.top().first;
        int nod = pq.top().second.second;
        int cnt = pq.top().second.first;
        pq.pop();
        if(cdist!=dist[cnt][nod])
            continue;
        for(auto [adj,c]:con[nod])
        {
            if(tip[adj]==0)
            {
                if(dist[cnt][adj]>0)
                {
                    dist[cnt][adj]=0;
                    pq.push({0,{cnt,adj}});
                }
            }
            else if(tip[adj]==2)
            {
                if(dist[cnt][adj] > cdist + c)
                {
                    dist[cnt][adj] = cdist + c;
                    pq.push({-dist[cnt][adj],{cnt,adj}});
                }
                if(cnt+1<=K && dist[cnt+1][adj] > (cdist + (ld)c)/2)
                {
                    dist[cnt+1][adj] = (cdist + (ld)c)/2;
                    pq.push({-dist[cnt+1][adj],{cnt+1,adj}});
                }
            }
            else
            {
                if(dist[cnt][adj] > cdist + c)
                {
                    dist[cnt][adj] = cdist + c;
                    pq.push({-dist[cnt][adj],{cnt,adj}});
                }
            }
        }
    }
    ld mnm=INF;
    for(int cnt=0;cnt<=K;cnt++)
        mnm = min(mnm, dist[cnt][H]);
    if(mnm==INF)
        return -1;
    else
        return mnm;
}
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 51544 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 52056 KB Correct.
2 Correct 29 ms 52184 KB Correct.
3 Correct 36 ms 52172 KB Correct.
4 Correct 28 ms 52312 KB Correct.
5 Correct 29 ms 52304 KB Correct.
6 Correct 33 ms 52828 KB Correct.
7 Correct 32 ms 53080 KB Correct.
8 Correct 20 ms 53888 KB Correct.
9 Correct 26 ms 52092 KB Correct.
10 Correct 37 ms 51964 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 52308 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1675 ms 56640 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 52232 KB Correct.
2 Correct 27 ms 52424 KB Correct.
3 Correct 29 ms 52272 KB Correct.
4 Correct 26 ms 53076 KB Correct.
5 Correct 26 ms 51828 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 52228 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 734 ms 55412 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 750 ms 55400 KB Wrong Answer.
2 Halted 0 ms 0 KB -