답안 #985149

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985149 2024-05-17T11:37:31 Z Sir_Ahmed_Imran 사이버랜드 (APIO23_cyberland) C++17
49 / 100
3000 ms 33992 KB
                              ///~~~LOTA~~~///
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 100000
#define K 31
int t;
int vis[N];
double dp[N][K];
vector<pair<int,double>> a[N];
void dfs(int v){
    if(vis[v] || v==t) 
        return;
    vis[v]=1;
    for(auto& i:a[v])
        dfs(i.ff);
}
double solve(int n,int m,int k,int h,vector<int> x,vector<int> y,vector<int> c,vector<int> arr){
    t=h;
    int p;
    double q,r;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++)
            dp[i][j]=1e17;
        a[i].clear();
        vis[i]=0;
    }
    for(int i=0;i<m;i++){
        a[x[i]].append({y[i],c[i]});
        a[y[i]].append({x[i],c[i]});
    }
    dfs(0);
    r=1e17;
    priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> Q;
    for(int i=0;i<n;i++)
        if(vis[i] && !arr[i])
            dp[i][0]=0;
    for(int j=dp[0][0]=0;j<=k;j++){
        for(int i=0;i<n;i++){
            Q.push({dp[i][j],i});
            vis[i]=0;
        }
        while(!Q.empty()){
            p=Q.top().ss;
            q=Q.top().ff;
            Q.pop();
            if(!vis[p]){
                vis[p]=1;
                if(p==h){
                    r=min(r,q);
                    continue;
                }
                if(j<k) dp[p][j+1]=min(q,dp[p][j+1]);
                for(auto& i:a[p]){
                    if(arr[i.ff]==2 && j<k)
                        dp[i.ff][j+1]=min(dp[i.ff][j+1],(q+i.ss)/2);
                    if(!vis[i.ff])
                        Q.push({q+i.ss,i.ff});
                }
            }
        }
    }
    if(r==1e17) r=-1;
    return r;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 6880 KB Correct.
2 Correct 31 ms 7168 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 254 ms 6996 KB Correct.
2 Correct 302 ms 6992 KB Correct.
3 Correct 289 ms 6996 KB Correct.
4 Correct 307 ms 6992 KB Correct.
5 Correct 297 ms 7444 KB Correct.
6 Correct 351 ms 10172 KB Correct.
7 Correct 461 ms 10084 KB Correct.
8 Correct 195 ms 13020 KB Correct.
9 Correct 114 ms 6748 KB Correct.
10 Correct 111 ms 6900 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 295 ms 6916 KB Correct.
2 Correct 280 ms 6892 KB Correct.
3 Correct 254 ms 7004 KB Correct.
4 Correct 126 ms 7064 KB Correct.
5 Correct 125 ms 6828 KB Correct.
6 Correct 73 ms 9820 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 697 ms 25044 KB Correct.
2 Incorrect 333 ms 7764 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 252 ms 7052 KB Correct.
2 Correct 293 ms 7200 KB Correct.
3 Correct 283 ms 7004 KB Correct.
4 Correct 366 ms 10580 KB Correct.
5 Correct 107 ms 6748 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 7104 KB Correct.
2 Correct 225 ms 7032 KB Correct.
3 Correct 759 ms 33992 KB Correct.
4 Correct 234 ms 8128 KB Correct.
5 Correct 115 ms 6744 KB Correct.
6 Correct 254 ms 7024 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 312 ms 6996 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3038 ms 12908 KB Time limit exceeded
2 Halted 0 ms 0 KB -