Submission #792587

# Submission time Handle Problem Language Result Execution time Memory
792587 2023-07-25T07:11:57 Z Warinchai Cyberland (APIO23_cyberland) C++17
68 / 100
3000 ms 39224 KB
#include "cyberland.h"
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >v[100005];
priority_queue<pair<double,pair<int,int> >,vector<pair<double,pair<int,int> > >,greater<pair<double,pair<int,int> > > >pq;
double dis[100005][35];
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    for(int i=0;i<=n;i++){
        for(int j=0;j<=30;j++){
            dis[i][j]=LLONG_MAX;
        }
        v[i].clear();
    }
    for(int i=0;i<m;i++){
        int st=x[i];
        int en=y[i];
        int cost=c[i];
        v[st].push_back({en,cost});
        v[en].push_back({st,cost});
    }
    dis[0][0]=0;
    pq.push({0,{0,0}});
    while(!pq.empty()){
        int node=pq.top().second.first;
        int used=pq.top().second.second;
        double cost=pq.top().first;
        pq.pop();
        if(node==h){
            continue;
        }
        for(int i=0;i<v[node].size();i++){
            int nx=v[node][i].first;
            double ed=v[node][i].second;
            if(arr[nx]==2){
                double nxu=(cost+ed)/2;
                double nxd=cost+ed;
                if(nxu<dis[nx][used+1]){
                    dis[nx][used+1]=nxu;
                    pq.push({nxu,{nx,used+1}});
                }
                if(nxd<dis[nx][used]){
                    dis[nx][used]=nxd;
                    pq.push({nxd,{nx,used}});
                }
            }else if(arr[nx]==0){
                if(dis[nx][used]>0){
                    dis[nx][used]=0;
                    pq.push({0,{nx,used}});
                }
            }else{
                if(cost+ed<dis[nx][used]){
                    dis[nx][used]=cost+ed;
                    pq.push({cost+ed,{nx,used}});
                }
            }
        }
    }
    double ans=LLONG_MAX;
    for(int i=0;i<=30;i++){
        ans=min(ans,dis[h][i]);
    }
    if(ans!=LLONG_MAX){
        return ans;
    }else{
        return -1;
    }
    //return -1;
}

Compilation message

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<v[node].size();i++){
      |                     ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2836 KB Correct.
2 Correct 18 ms 3072 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3444 KB Correct.
2 Correct 24 ms 4020 KB Correct.
3 Correct 28 ms 3888 KB Correct.
4 Correct 24 ms 3924 KB Correct.
5 Correct 24 ms 3900 KB Correct.
6 Correct 21 ms 6868 KB Correct.
7 Correct 35 ms 6848 KB Correct.
8 Correct 16 ms 9736 KB Correct.
9 Correct 22 ms 3484 KB Correct.
10 Correct 23 ms 3440 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3912 KB Correct.
2 Correct 30 ms 3796 KB Correct.
3 Correct 22 ms 3916 KB Correct.
4 Correct 32 ms 3052 KB Correct.
5 Correct 25 ms 3540 KB Correct.
6 Correct 7 ms 5608 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 310 ms 23284 KB Correct.
2 Correct 495 ms 3916 KB Correct.
3 Correct 393 ms 3940 KB Correct.
4 Correct 452 ms 3972 KB Correct.
5 Correct 297 ms 3584 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3924 KB Correct.
2 Correct 22 ms 3940 KB Correct.
3 Correct 24 ms 4000 KB Correct.
4 Correct 26 ms 6996 KB Correct.
5 Correct 25 ms 3452 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 25 ms 3848 KB Correct.
2 Correct 21 ms 3872 KB Correct.
3 Correct 49 ms 29928 KB Correct.
4 Correct 19 ms 5796 KB Correct.
5 Correct 25 ms 3572 KB Correct.
6 Correct 25 ms 3660 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 273 ms 4292 KB Correct.
2 Correct 32 ms 4080 KB Correct.
3 Execution timed out 3071 ms 39224 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 288 ms 3996 KB Correct.
2 Correct 32 ms 4048 KB Correct.
3 Incorrect 258 ms 38796 KB Wrong Answer.
4 Halted 0 ms 0 KB -