답안 #743755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743755 2023-05-18T00:04:54 Z rominanafu 악어의 지하 도시 (IOI11_crocodile) C++11
0 / 100
3 ms 3412 KB
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
 
using namespace std;
typedef long long ll;
 
vector<pii > edge[100005];
pii tiempo[100005];
priority_queue<pii > q;
 
void tiempo_min() {
    pii a;
    int s;
    while (!q.empty()) {
        a = q.top();
        q.pop();
        for(auto v:edge[a.second]) {
            s = (a.first * (-1)) + v.second;
            if (tiempo[v.first].first == -1) {
                tiempo[v.first].first = s;
            } else if (s < tiempo[v.first].first) {
                tiempo[v.first].second = tiempo[v.first].first;
                tiempo[v.first].first = s;
                q.push({tiempo[v.first].second * (-1), v.first});
            } else if (s < tiempo[v.first].second || tiempo[v.first].second == -1) {
                tiempo[v.first].second = s;
                q.push({s * (-1), v.first});
            }
        }
    }
}
 
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[])
{
    memset(tiempo, -1, sizeof(tiempo));
    int a, b, t;
    for(int i=0; i<m; i++) {
        a = R[i][0];
        b = R[i][1];
        t = L[i];
        edge[a].push_back({b, t});
        edge[b].push_back({a, t});
    }
    for(int i=0; i<k; i++) {
        a = P[i];
        tiempo[a].first = 0;
        tiempo[a].second = 0;
        q.push({0, a});
    }
    tiempo_min();
    return tiempo[0].second;
}
 
/**
4 4 1
0 1 9
0 3 10
1 2 40
2 3 100
2
**/

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:36:38: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'struct std::pair<int, int>' with no trivial copy-assignment [-Wclass-memaccess]
   36 |     memset(tiempo, -1, sizeof(tiempo));
      |                                      ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from crocodile.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'struct std::pair<int, int>' declared here
  211 |     struct pair
      |            ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Incorrect 3 ms 3412 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Incorrect 3 ms 3412 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Incorrect 3 ms 3412 KB Output isn't correct
4 Halted 0 ms 0 KB -