Submission #740522

# Submission time Handle Problem Language Result Execution time Memory
740522 2023-05-12T16:05:14 Z rominanafu Crocodile's Underground City (IOI11_crocodile) C++11
46 / 100
4 ms 4464 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];
pll tiempo[100005];
bool vis[100005];

ll tiempo_min(int act) {
    if (vis[act])
        return -1;
    if (tiempo[act].second != -1)
        return tiempo[act].second;
    ll r;
    vis[act] = true;
    for(auto a:edge[act]) { /// a.first = sig sala, a.second = tiempo
        r = tiempo_min(a.first);
        if (r == -1)
            continue;
        r += a.second;
        if (tiempo[act].first == -1 || r < tiempo[act].first) {
            tiempo[act].second = tiempo[act].first;
            tiempo[act].first = r;
        } else if (tiempo[act].second == -1 || r < tiempo[act].second) {
            tiempo[act].second = r;
        }
    }
    vis[act] = false;
    return tiempo[act].second;
}

int travel_plan(int n, int m, int R[][2], int L[], int k, int P[])
{
    memset(tiempo, -1LL, 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;
    }
    ll resp = tiempo_min(0);
    return resp;
}

/**
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:37:40: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'struct std::pair<long long int, long long int>' with no trivial copy-assignment [-Wclass-memaccess]
   37 |     memset(tiempo, -1LL, 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<long long int, long long int>' declared here
  211 |     struct pair
      |            ^~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 3 ms 4308 KB Output is correct
5 Correct 3 ms 4308 KB Output is correct
6 Correct 3 ms 4180 KB Output is correct
7 Correct 3 ms 4308 KB Output is correct
8 Correct 3 ms 4308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 3 ms 4308 KB Output is correct
5 Correct 3 ms 4308 KB Output is correct
6 Correct 3 ms 4180 KB Output is correct
7 Correct 3 ms 4308 KB Output is correct
8 Correct 3 ms 4308 KB Output is correct
9 Correct 4 ms 4464 KB Output is correct
10 Incorrect 3 ms 4180 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 3 ms 4308 KB Output is correct
5 Correct 3 ms 4308 KB Output is correct
6 Correct 3 ms 4180 KB Output is correct
7 Correct 3 ms 4308 KB Output is correct
8 Correct 3 ms 4308 KB Output is correct
9 Correct 4 ms 4464 KB Output is correct
10 Incorrect 3 ms 4180 KB Output isn't correct
11 Halted 0 ms 0 KB -