제출 #867344

#제출 시각아이디문제언어결과실행 시간메모리
867344lalig777Finding Routers (IOI20_routers)C++14
컴파일 에러
0 ms0 KiB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> find_routers(int l, int n, int q){
    vector<int>ans(n);
    ans[0]=0;
    if (l%2!=0) l--;
    vector<pair<int,int>>memoria(n, make_pair(0, 1e9));
    for (int i=1; i<n; i++){
        int right=min(l-2*(n-i-1), 2*memoria[i].second-ans[i-1]-2);
        int left=max(ans[i-1]+2, 2*memoria[i-1].first-ans[i-1]);
        int m;
        bool tipo=false;
        while (left!=right){
            m=(right-left)/2+left;
            if (m%2!=0) m++;
            if (left+2==right){
                int m3=(left-ans[i-1])/2+ans[i-1];
                if (m3%2==0) m3+=2;
                else m3++;
                if (use_detector(m3)==i) right-=2;
                else left+=2;
            }
            else if (tipo==false){
                if (use_detector(m)==i+1){
                    memoria[i+1].second=min(memoria[i+1].second, m);
                    right=m-2;
                }else{
                    memoria[i].first=max(memoria[i].first, m);
                    tipo=true;
                }
            }else{
                int m2=(right-m)/2+m;
                if (m2%2!=0) m2++;
                if (use_detector(m2)==i+1){
                    memoria[i+1].second=min(memoria[i+1].second, m2);
                    right=m-2;
                    tipo=false;
                }else memoria[i].first=max(memoria[i].first, m2);
            }
        }ans[i]=left;
    }return ans;
}

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

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:31:21: error: 'use_detector' was not declared in this scope
   31 |                 if (use_detector(m3)==i) right-=2;
      |                     ^~~~~~~~~~~~
routers.cpp:35:21: error: 'use_detector' was not declared in this scope
   35 |                 if (use_detector(m)==i+1){
      |                     ^~~~~~~~~~~~
routers.cpp:45:21: error: 'use_detector' was not declared in this scope
   45 |                 if (use_detector(m2)==i+1){
      |                     ^~~~~~~~~~~~