Submission #880339

# Submission time Handle Problem Language Result Execution time Memory
880339 2023-11-29T07:54:54 Z Mardonbekhazratov Cyberland (APIO23_cyberland) C++17
15 / 100
26 ms 2396 KB
#include "cyberland.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define ll long long
const ll INF=1e18;

double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    bool subtask=true;
    for(int i=0;i<N;i++) if(arr[i]!=1) subtask=false;
    if(subtask){
        vector<vector<pair<int,int>>>v(N);
        for(int i=0;i<M;i++){
            v[x[i]].push_back({y[i],c[i]});
            v[y[i]].push_back({x[i],c[i]});
        }
        vector<bool>vis(N,0);
        priority_queue<pair<ll,int>>q;
        vector<ll>dp(N,INF);
        dp[0]=0;
        q.push({0,0});
        while(!q.empty()){
            int x=q.top().second;
            q.pop();
            if(vis[x]) continue;
            vis[x]=true;
            for(auto [z,y]:v[x]){
                if(dp[x]+y<dp[z]){
                    dp[z]=dp[x]+y;
                    q.push({-dp[z],z});
                }
            }
        }
        if(dp[H]==INF) return -1.0;
        return 1.0*dp[H];
    }
    else{
        int l=-1,r=0;
        for(int i=1;i<H;i++){
            if(arr[i]==2){
                l=i;
            }
            if(arr[i]==0){
                r=i;
            }
        }
        double ans=0.0;
        for(int i=r;i<H;i++){
            ans+=c[i];
            if(i==l){
                int j=0;
                double g=c[i-1];
                if(i+1!=H) g=min(g,1.0*c[i]);
                while(j<K&&ans>2*g){
                    ans=(ans+2*g)/2;
                    j++;
                }
            }
        }
        return ans;
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 620 KB Correct.
2 Correct 21 ms 604 KB Correct.
3 Correct 20 ms 604 KB Correct.
4 Correct 20 ms 564 KB Correct.
5 Correct 25 ms 560 KB Correct.
6 Correct 21 ms 1436 KB Correct.
7 Correct 26 ms 1352 KB Correct.
8 Correct 10 ms 2396 KB Correct.
9 Correct 20 ms 516 KB Correct.
10 Correct 20 ms 348 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 348 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2140 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 604 KB Correct.
2 Correct 20 ms 568 KB Correct.
3 Correct 19 ms 600 KB Correct.
4 Correct 18 ms 1116 KB Correct.
5 Correct 18 ms 344 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 344 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -