제출 #1230148

#제출 시각아이디문제언어결과실행 시간메모리
1230148lioowFinding Routers (IOI20_routers)C++20
컴파일 에러
0 ms0 KiB
#include "routers.h"
#include <vector>
#include <cassert>
#include <cstdio>
#include <algorithm>
using namespace std;

std::vector<int> find_routers(int le, int n, int q) {
    vector<int>ans(n);
    ans[0]=0;
    for(int i=1;i<=n-1;i++){
    	int l=ans[i-1]+1;
    	int r=le-1;
    	int an=-1;
    	int lol=-1;
    	while(l<r){
    		int mid=(l+r)/2;
    		int nw=use_detector(mid);
    		if(nw>=i){
    			an=mid;
    			r=mid-1;
			} else {
				if(nw==i-1) lol=ans[i-1]+2*(nw-ans[i-1]);
				l=mid+1;
			}
		}
		if(lol==-1) ans[i]=nw;
		else ans[i]=lol;
	}
	return ans;
}

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

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:27:36: error: 'nw' was not declared in this scope; did you mean 'n'?
   27 |                 if(lol==-1) ans[i]=nw;
      |                                    ^~
      |                                    n