Submission #237172

# Submission time Handle Problem Language Result Execution time Memory
237172 2020-06-05T05:00:26 Z Autoratch Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int> 

const int N = 1e5 + 1;

vector<pair<int,int> > adj[N];
vector<int> ep;
bool epp[N];
priority_queue<pii,vector<pii>,greater<pii> > q;
int dist[N],dis1[N],dis2[N];
bool visited[N];

int travel_plan(int n,int m,int r[][2],int l[],int k,int p[])
{
    for(int i = 0;i < m;i++)
    {
        int a = r[i][0],b = r[i][1],d = l[i];
        adj[a].push_back({d,b});
        adj[b].push_back({d,a});
    }
    for(int i = 0;i < k;i++) ep.push_back(p[i]);
    for(int i = 0;i < n;i++) dist[i] = dis1[i] = dis2[i] = INT_MAX;
    for(int x : ep) dist[x] = dis1[x] = dis2[x] = 0,q.push({0,x}),epp[x] = true;
    while(!q.empty())
    {
        int u = q.top().second;
        q.pop();
        if(visited[u]) continue;
        visited[u] = true;
        for(auto [d,v] : adj[u]) if(dist[u]+d<dist[v]) dist[v] = dist[u]+d,q.push({dist[v],v});
    }
    for(int i = 0;i < n;i++) visited[i] = false;
    for(int x : ep) q.push({0,x});
    while(!q.empty())
    {
        int u = q.top().second;
        q.pop();
        if(visited[u]) continue;
        visited[u] = true;
        for(auto [d,v] : adj[u]) if(dist[u]+d!=dist[v])
        {
            if(dis2[u]+d<dis2[v]) ds2[v] = dis2[u]+d,q.push({dis2[v],v});
        }
    }
    return dis2[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:32:18: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
         for(auto [d,v] : adj[u]) if(dist[u]+d<dist[v]) dist[v] = dist[u]+d,q.push({dist[v],v});
                  ^
crocodile.cpp:42:18: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
         for(auto [d,v] : adj[u]) if(dist[u]+d!=dist[v])
                  ^
crocodile.cpp:44:35: error: 'ds2' was not declared in this scope
             if(dis2[u]+d<dis2[v]) ds2[v] = dis2[u]+d,q.push({dis2[v],v});
                                   ^~~
crocodile.cpp:44:35: note: suggested alternative: 'dis2'
             if(dis2[u]+d<dis2[v]) ds2[v] = dis2[u]+d,q.push({dis2[v],v});
                                   ^~~
                                   dis2