Submission #900392

# Submission time Handle Problem Language Result Execution time Memory
900392 2024-01-08T08:23:04 Z JakobZorz Tropical Garden (IOI11_garden) C++17
Compilation error
0 ms 0 KB
#include"garden.h"
#include"gardenlib.h"
#include<iostream>
#include<vector>
using namespace std;

int n; // num nodes
int m; // num edges
int p; // destination
vector<vector<int>>nodes; // lowest node and second lowest node
vector<vector<int>>dist;

void add_conn(int node,int dest){
    if(nodes[node][0]==-1){
        nodes[node]={dest,dest};
    }else if(nodes[node][0]==nodes[node][1]){
        nodes[node][1]=dest;
    }
}

int dfs(int node,int blocked){
    if(dist[node][blocked]!=-1)
        return dist[node][blocked];
    dist[node][blocked]=1e9;
    int blocked2=0;
    int nxt=nodes[node][blocked];
    if(nodes[nxt][0]==node&&nodes[nxt][1]!=-1)
        blocked2=1;
    dist[node][blocked]=dfs(nxt,blocked2)+1;
    return dist[node][blocked];
}

void count_routes(int N,int M,int P,int R[][2],int Q,int G[]){
    n=N;
    m=M;
    p=P;
    nodes=vector<vector<int>>(n,{-1,-1});
    dist=vector<vector<int>>(n,{-1,-1});
    for(int i=0;i<m;i++){
        add_conn(R[i][0],R[i][1]);
        add_conn(R[i][1],R[i][0]);
    }
    dist[p]={0,0};
    
    unordered_map<int,int>mp;
    for(int i=0;i<n;i++){
        mp[dfs(i,0)]++;
    }
    
    for(int i=0;i<Q;i++)
        answer(mp[G[i]]);
}

Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:45:5: error: 'unordered_map' was not declared in this scope
   45 |     unordered_map<int,int>mp;
      |     ^~~~~~~~~~~~~
garden.cpp:5:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
    4 | #include<vector>
  +++ |+#include <unordered_map>
    5 | using namespace std;
garden.cpp:45:19: error: expected primary-expression before 'int'
   45 |     unordered_map<int,int>mp;
      |                   ^~~
garden.cpp:47:9: error: 'mp' was not declared in this scope; did you mean 'p'?
   47 |         mp[dfs(i,0)]++;
      |         ^~
      |         p
garden.cpp:51:16: error: 'mp' was not declared in this scope; did you mean 'p'?
   51 |         answer(mp[G[i]]);
      |                ^~
      |                p