Submission #465475

# Submission time Handle Problem Language Result Execution time Memory
465475 2021-08-16T08:05:00 Z MohamedFaresNebili Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    int n=N, m=M, k=K; vector<pair<long long, int>>adj[n]; vector<int> dis(n, -1);
    vector<bool>exit(n, false); vector<long long>d(n, 1e10); vector<bool>queued(n, false);
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>pq;
    for(int l=0;l<m;l++) {
        int a=R[l][0], b=R[l][1]; long long w=L[l];
        adj[a].push_back({b, w});
        adj[b].push_back({a, w});
    }
    for(int l=0;l<k;l++) {
        int a=P[l]; dis[a]=0;
        pq.push({0, a}); d[a]=0;
    }
    vector<long long>len[n]; vector<int>income(n, 0); queue<int>q;
    while(!pq.empty()) {
        int a=pq.top().second; long long w=pq.top().second;
      	queued[a]=true; pq.pop();
        for(auto u:adj[a]) {
            int to=u.first; long long s=u.second;
            if(queued[to]) continue; q.push(to);
            len[to].push_back(d[a]+s); income[to]++;
        }
      	if(pq.empty()) {
          while(!q.empty()) {
            	int to=q.front(); q.pop();
                if(income[to]>1) {
                  sort(len[to].begin(), len[to].end());
                  pq.push({len[to][1], to});
                  d[to]=len[to][1];
            	}
          }
        }
    }
    return (d[0]!=1e10?d[0]:-1);
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:24:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   24 |             if(queued[to]) continue; q.push(to);
      |             ^~
crocodile.cpp:24:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   24 |             if(queued[to]) continue; q.push(to);
      |                                      ^
crocodile.cpp:20:42: warning: unused variable 'w' [-Wunused-variable]
   20 |         int a=pq.top().second; long long w=pq.top().second;
      |                                          ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -