답안 #985067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985067 2024-05-17T10:19:45 Z shjeong 사이버랜드 (APIO23_cyberland) C++17
44 / 100
2126 ms 60252 KB
#include <vector>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <cassert>
#include <list>
using namespace std;
#define all(x) x.begin(), x.end()
#define rll(x) x.rbegin(), x.rend()
#define comp(x) x.erase(unique(all(x)), x.end())
#define MOD 1000000007
#define MOD2 998244353
#define debug(x) cout << #x<<" is "<<x<<"\n";
#define X first
#define Y second
#define DEB cout<<"[DEBUG]"
#define PAIR(a,b) "("<<a<<", "<<b<<")"
#define PRINT1(V) DEB<<#V<<endl; for(auto i : V)DEB<<i<<"\n"
#define PRINT2(V) DEB<<#V<<endl; for(auto [a,b] : V)DEB<<PAIR(a,b)<<"\n";
typedef long long ll;
typedef __int128_t lll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef tuple<ld,ll,bool> Pd;
vector<P> adj[202020];
ld dist[202020][33];
ll p[202020];
ll find(ll x){
    if(p[x]<0)return x;
    return p[x] = find(p[x]);
}
void merge(ll x, ll y){
    x = find(x), y = find(y);
    if(x==y)return;
    p[y]=x;
}
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) {
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j <= K ; j++)dist[i][j] = 1e15;
        adj[i].clear();
        p[i]=-1;
    }
    for(int i = 0 ; i < M ; i++){
        if(x[i] != H and y[i] != H)merge(x[i],y[i]);
        adj[x[i]].push_back({y[i],c[i]});
        adj[y[i]].push_back({x[i],c[i]});
    }
    priority_queue<Pd,vector<Pd>,greater<Pd>> pq[33];
    for(int i = 0 ; i < N ; i++)if(arr[i]==0 and find(0) == find(i)){
        for(int j = 0 ; j <= K ; j++)dist[i][j]=0, pq[j].push({0,i,0});
    }
    ld ret = 1e15;
    pq[0].push({0,0,0});
    dist[0][0] = 0;
    for(int i = 0 ; i <= K ; i++){
        while(pq[i].size()){
            auto [d,cur,_] = pq[i].top(); pq[i].pop();
            if(dist[cur][i] < d)continue;
            if(!_ and arr[cur]==2 and i<K){
                if(dist[cur][i+1] > d/2.0){
                    dist[cur][i+1] = d/2.0;
                    pq[i+1].push({d/2.0,cur,1});
                }
            }
            for(auto [next,w] : adj[cur]){
                if(dist[next][i] > d+w){
                    dist[next][i] = d+w;
                    pq[i].push({d+w,next,0});
                }
            }
        }
        ret = min(ret, dist[H][i]);
    }
    if(ret==1e15)return -1;
    return (double)ret;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 8784 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 9304 KB Correct.
2 Correct 32 ms 9564 KB Correct.
3 Correct 30 ms 9300 KB Correct.
4 Correct 32 ms 9420 KB Correct.
5 Correct 34 ms 9552 KB Correct.
6 Correct 35 ms 16212 KB Correct.
7 Correct 37 ms 16464 KB Correct.
8 Correct 18 ms 21004 KB Correct.
9 Correct 29 ms 9048 KB Correct.
10 Correct 28 ms 9040 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 228 ms 10108 KB Correct.
2 Correct 280 ms 9976 KB Correct.
3 Correct 238 ms 9756 KB Correct.
4 Correct 146 ms 9216 KB Correct.
5 Correct 156 ms 9164 KB Correct.
6 Correct 62 ms 18916 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 366 ms 60252 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 9308 KB Correct.
2 Correct 29 ms 9488 KB Correct.
3 Correct 28 ms 9308 KB Correct.
4 Correct 29 ms 16632 KB Correct.
5 Correct 31 ms 9020 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 9964 KB Correct.
2 Correct 97 ms 9916 KB Correct.
3 Correct 59 ms 55384 KB Correct.
4 Correct 101 ms 17632 KB Correct.
5 Correct 90 ms 9044 KB Correct.
6 Correct 112 ms 9888 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 171 ms 9948 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2126 ms 41408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -