답안 #976334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976334 2024-05-06T12:43:14 Z kwongweng 사이버랜드 (APIO23_cyberland) C++17
44 / 100
33 ms 8788 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef vector<vector<ll>> vll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define ms memset
#define fi first
#define se second

double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) {
    vii g[N];
    FOR(i,0,M){
        g[x[i]].pb({y[i],c[i]});
        g[y[i]].pb({x[i],c[i]});
    }
    vi used(N);
    vi bfs; bfs.pb(0); used[0]=1;
    FOR(i,0,bfs.size()){
        int u = bfs[i]; if (u==H) continue;
        for (ii edge : g[u]){
            int v = edge.fi;
            if (used[v]) continue;
            bfs.pb(v); used[v]=1;
        }
    }
    if (!used[H]) return -1; 
    vector<double> dist(N);
    set<pair<double,int>> st;
    st.insert({dist[0],0});
    FOR(i,1,N){
        if (arr[i]==0 && used[i]){
            st.insert({dist[i],i});
        }else{
            dist[i]=1e18;
        }
    }
    while (!st.empty()){
        int u = (*st.begin()).se; st.erase(st.begin());
        for (ii edge : g[u]){
            int v = edge.fi; int w = edge.se;
            if (dist[v] > dist[u] + w){
                st.erase({dist[v],v});
                dist[v] = dist[u]+w;
                st.insert({dist[v],v});
            }
        }
    }
    return dist[H];
}

Compilation message

cyberland.cpp: In function 'double solve(int, int, int, int, vi, vi, vi, vi)':
cyberland.cpp:10:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   25 |     FOR(i,0,bfs.size()){
      |         ~~~~~~~~~~~~~~                 
cyberland.cpp:25:5: note: in expansion of macro 'FOR'
   25 |     FOR(i,0,bfs.size()){
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 604 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 604 KB Correct.
2 Correct 27 ms 592 KB Correct.
3 Correct 25 ms 588 KB Correct.
4 Correct 28 ms 588 KB Correct.
5 Correct 26 ms 844 KB Correct.
6 Correct 24 ms 1564 KB Correct.
7 Correct 29 ms 1528 KB Correct.
8 Correct 12 ms 2648 KB Correct.
9 Correct 23 ms 492 KB Correct.
10 Correct 25 ms 876 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 592 KB Correct.
2 Correct 28 ms 1108 KB Correct.
3 Correct 26 ms 1224 KB Correct.
4 Correct 26 ms 1116 KB Correct.
5 Correct 25 ms 1116 KB Correct.
6 Correct 7 ms 1604 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 6492 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 620 KB Correct.
2 Correct 24 ms 584 KB Correct.
3 Correct 23 ms 604 KB Correct.
4 Correct 25 ms 1372 KB Correct.
5 Correct 19 ms 508 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 604 KB Correct.
2 Correct 21 ms 1104 KB Correct.
3 Correct 33 ms 8788 KB Correct.
4 Correct 16 ms 1892 KB Correct.
5 Correct 22 ms 1104 KB Correct.
6 Correct 22 ms 1108 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 604 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 600 KB Wrong Answer.
2 Halted 0 ms 0 KB -