답안 #782831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782831 2023-07-14T10:09:35 Z vjudge1 사이버랜드 (APIO23_cyberland) C++17
44 / 100
3000 ms 14484 KB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
//#define mid (start+end)/2
//#define OYY 10000
//#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
const long double OYY=100000000000000000000;

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){
    int n=N;
    int m=M;
    int k=K;
    vector <pair<int,int>> v[n];
    for(int i=0;i<m;i++){
        int a=x[i];
        int b=y[i];
        int co=c[i];
        v[a].push_back({b,co});
        v[b].push_back({a,co});
    }
    vector <long double> uza(n,OYY);
    uza[0]=0;
    for(int ip=0;ip<=k+2;ip++){
        set <pair<long double,int>> st;
        for(int i=0;i<n;i++){
            st.insert({uza[i],i});
        }
        while(!st.empty()){
            int node=st.begin()->second;
            st.erase(st.begin());
            if(node==H)continue;
            for(int i=0;i<v[node].size();i++){
                int go=v[node][i].first;
                int cost=v[node][i].second;
                if(uza[go]>uza[node]+cost){
                    st.erase({uza[go],go});
                    uza[go]=uza[node]+cost;
                    st.insert({uza[go],go});
                }
            }
        }
        auto ne=uza;
        for(int j=0;j<n;j++){
            if(uza[j]<OYY/10){
                if(arr[j]==0)ne[j]=0;
            }
            else if(arr[j]==2 && ip>1 && ip!=k+2){
                for(int i=0;i<v[j].size();i++){
                    int go=v[j][i].first;
                    int cost=v[j][i].second;
                    ne[go]=min(ne[go],uza[j]/2+(long double)cost);
                }
            }
        }
        uza=ne;
    }
    if(uza[H]>=OYY/10){
        return -1;
    }
    return uza[H];

}

Compilation message

cyberland.cpp:7:23: warning: integer constant is too large for its type
    7 | const long double OYY=100000000000000000000;
      |                       ^~~~~~~~~~~~~~~~~~~~~
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:32:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             for(int i=0;i<v[node].size();i++){
      |                         ~^~~~~~~~~~~~~~~
cyberland.cpp:48:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |                 for(int i=0;i<v[j].size();i++){
      |                             ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 524 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 268 ms 648 KB Correct.
2 Correct 340 ms 596 KB Correct.
3 Correct 323 ms 640 KB Correct.
4 Correct 333 ms 640 KB Correct.
5 Correct 323 ms 660 KB Correct.
6 Correct 374 ms 2228 KB Correct.
7 Correct 452 ms 2192 KB Correct.
8 Correct 209 ms 4088 KB Correct.
9 Correct 191 ms 536 KB Correct.
10 Correct 168 ms 492 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 290 ms 620 KB Correct.
2 Correct 287 ms 556 KB Correct.
3 Correct 262 ms 620 KB Correct.
4 Correct 204 ms 520 KB Correct.
5 Correct 189 ms 536 KB Correct.
6 Correct 71 ms 1900 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 688 ms 10964 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 244 ms 628 KB Correct.
2 Correct 251 ms 624 KB Correct.
3 Correct 270 ms 612 KB Correct.
4 Correct 262 ms 2208 KB Correct.
5 Correct 184 ms 460 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 261 ms 644 KB Correct.
2 Correct 235 ms 656 KB Correct.
3 Correct 549 ms 14484 KB Correct.
4 Correct 213 ms 1676 KB Correct.
5 Correct 177 ms 512 KB Correct.
6 Correct 230 ms 588 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 255 ms 536 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3076 ms 312 KB Time limit exceeded
2 Halted 0 ms 0 KB -