Submission #699546

# Submission time Handle Problem Language Result Execution time Memory
699546 2023-02-17T10:29:16 Z amin Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
646 ms 71872 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    //cout<<1000000<<endl;
    int n=N;
    int m=M;
    vector<int>v[n],c[n];
    int co[n];

    for(int i=0;i<n;i++)
    {
        co[i]=0;
    }
    for(int i=0;i<m;i++)
    {
        int x=R[i][0];
        int y=R[i][1];
       // x--;
       // y--;
        v[x].push_back(y);
        v[y].push_back(x);
        c[x].push_back(L[i]);
        c[y].push_back(L[i]);


    }
    priority_queue<pair<int,int> >pq;
    int vis[n];

    for(int i=0;i<K;i++)
    {
       // P[i]--;
        co[P[i]]=1;
        pq.push({0,P[i]});

    }
    while(!pq.empty())
    {
        int val=-pq.top().first;
        int in=pq.top().second;
        //Acout<<in<<endl;
        pq.pop();
        if(co[in]==1)
        {
            co[in]++;
            if(in==0)
            {
                return val;
            }
        }else
        if(co[in]==0)
        {
            co[in]++;
            continue;
        }else
        continue;

        for(int i=0;i<v[in].size();i++)
        {
            pq.push({-(val+c[in][i]),v[in][i]});

        }

    }







}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:60:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         for(int i=0;i<v[in].size();i++)
      |                     ~^~~~~~~~~~~~~
crocodile.cpp:30:9: warning: unused variable 'vis' [-Wunused-variable]
   30 |     int vis[n];
      |         ^~~
crocodile.cpp:74:1: warning: control reaches end of non-void function [-Wreturn-type]
   74 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 448 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 448 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 5 ms 1088 KB Output is correct
13 Correct 4 ms 1220 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 448 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 5 ms 1088 KB Output is correct
13 Correct 4 ms 1220 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 549 ms 71872 KB Output is correct
17 Correct 99 ms 17256 KB Output is correct
18 Correct 128 ms 18888 KB Output is correct
19 Correct 646 ms 70616 KB Output is correct
20 Correct 306 ms 64504 KB Output is correct
21 Correct 45 ms 7084 KB Output is correct
22 Correct 582 ms 46104 KB Output is correct