Submission #988629

#TimeUsernameProblemLanguageResultExecution timeMemory
988629komasanBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
// #include "boxes.h"
#include<bits/stdc++.h>
using namespace std;

#define            fi first
#define            se second
#define            db double
#define            ll long long
#define           ull unsigned long long
#define           ios 
#define           int ll

template<class A,class B> inline void maximize(A& x, B y) {x = max(x, y);};
template<class A,class B> inline void minimize(A& x, B y) {x = min(x, y);};

const long long INF = 1e18;
const long long mod = 1e9 + 7;
const int N = 2e5 + 100;

pair<int, int> dist[N];
vector<pair<int, int>> edge[N];
// int n = 5;
// vector<int> u = {0, 0, 3, 2};
// vector<int> v = {1, 2, 2, 4};
// vector<int> l = {2, 3, 1, 4};
// vector<int> p = {1, 3, 4};
int solve(int n, int m, int k, int a[]) {
//int32_t main() {

    int n;
    vector<int> u;
    vector<int> v;
    vector<int> l;
    vector<int> p;
    int m = (int)u.size();
    for (int i = 0; i < m; i++) {

        edge[u[i]].push_back(make_pair(v[i], l[i]));
        edge[v[i]].push_back(make_pair(u[i], l[i]));

    }

    // memset(dist, 0x3f, sizeof(dist));
    for (int i = 0; i < n; i++)
        dist[i] = make_pair(INF, INF);

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> cur;
    for (int x : p) {

        dist[x] = make_pair(0, 0);
        cur.push(make_pair(0, x));

    }

    while (!cur.empty()) {

        int u = cur.top().se;
        int w = cur.top().fi;
        cur.pop();

        if (dist[u].fi < w)
            continue;

        for (pair<int, int> x : edge[u])
            if (dist[x.fi].fi > w + x.se) {

                dist[x.fi].fi = w + x.se;
                if (dist[x.fi].fi < dist[x.fi].se)
                    swap(dist[x.fi].fi, dist[x.fi].se);
                
                cur.push(make_pair(dist[x.fi].fi, x.fi));

            }

    }    

    return dist[0].fi;

}

Compilation message (stderr)

boxes.cpp: In function 'long long int solve(long long int, long long int, long long int, long long int*)':
boxes.cpp:30:9: error: declaration of 'long long int n' shadows a parameter
   30 |     int n;
      |         ^
boxes.cpp:27:15: note: 'long long int n' previously declared here
   27 | int solve(int n, int m, int k, int a[]) {
      |               ^
boxes.cpp:35:9: error: declaration of 'long long int m' shadows a parameter
   35 |     int m = (int)u.size();
      |         ^
boxes.cpp:27:22: note: 'long long int m' previously declared here
   27 | int solve(int n, int m, int k, int a[]) {
      |                      ^
boxes.cpp:57:13: warning: declaration of 'u' shadows a previous local [-Wshadow]
   57 |         int u = cur.top().se;
      |             ^
boxes.cpp:31:17: note: shadowed declaration is here
   31 |     vector<int> u;
      |                 ^
boxes.cpp:27:15: warning: unused parameter 'n' [-Wunused-parameter]
   27 | int solve(int n, int m, int k, int a[]) {
      |               ^
boxes.cpp:27:22: warning: unused parameter 'm' [-Wunused-parameter]
   27 | int solve(int n, int m, int k, int a[]) {
      |                      ^
boxes.cpp:27:29: warning: unused parameter 'k' [-Wunused-parameter]
   27 | int solve(int n, int m, int k, int a[]) {
      |                             ^
boxes.cpp:27:36: warning: unused parameter 'a' [-Wunused-parameter]
   27 | int solve(int n, int m, int k, int a[]) {
      |                                    ^