제출 #309295

#제출 시각아이디문제언어결과실행 시간메모리
309295georgerapeanuFinding Routers (IOI20_routers)C++14
컴파일 에러
0 ms0 KiB
#include "routers.h"
#include <vector>
#include <algorithm>


using namespace std;

map<int,int> memo;

int my_detector(int pos){
    if(memo.count(pos) == 0){
        memo[pos] = use_detector(pos);
    }

    return memo[pos];
}

void solve(int l,int r,int l_val,int r_val,vector<int> &lst_pos){
    if(l_val == r_val){
        lst_pos[l_val] = max(lst_pos[l_val],r);
        return ;
    }
    
    int m = (l + r) / 2;

    solve(l,m,l_val,my_detector(m),lst_pos);
    solve(m + 1,r,my_detector(m + 1),r_val,lst_pos);
}

vector<int> find_routers(int l, int n, int q) {
	vector<int> ans(n,0);
    vector<int> lst_pos(n,0);
    
    solve(0,l,0,n - 1,lst_pos);

    vector<pair<int,int> > tmp;

    for(int i = 0;i < (int)lst_pos.size();i++){
        tmp.push_back({lst_pos[i],i});
    }

    ans[0] = 0;

    for(int i = 0;i < (int)tmp.size() - 1;i++){
        if(tmp[i].second < tmp[i + 1].second){
            ans[tmp[i + 1].second] = 2 * tmp[i].first - ans[tmp[i].second];
        }
        else{
            ans[tmp[i + 1].second] = 2 * tmp[i].first - ans[tmp[i].second] + 1;
        }
    }

    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

routers.cpp:8:1: error: 'map' does not name a type
    8 | map<int,int> memo;
      | ^~~
routers.cpp: In function 'int my_detector(int)':
routers.cpp:11:8: error: 'memo' was not declared in this scope
   11 |     if(memo.count(pos) == 0){
      |        ^~~~
routers.cpp:15:12: error: 'memo' was not declared in this scope
   15 |     return memo[pos];
      |            ^~~~