제출 #433051

#제출 시각아이디문제언어결과실행 시간메모리
433051ACmachineFinding Routers (IOI20_routers)C++17
컴파일 에러
0 ms0 KiB
#include "routers.h" #include <bits/stdc++.h> using namespace std; #define FOR(i, j, k, l) for(int i = (j); i < (k); i += (l)) #define FORD(i, j, k, l) for(int i = (j); i >= (k); i -= (l)) #define REP(i, n) FOR(i, 0, n, 1) #define REPD(i, n) FORD(i, n, 0, 1) #define pb push_back typedef long long ll; std::vector<int> find_routers(int l, int n, int q) { vector<int> ans; ans.pb(0); vector<int> mapka(l, -1); auto get = [&](int x){ if(mapka[x] != -1) return mapka[x]; return mapka[x] = use_detector(x); }; function<int(int, int, int)> dfs = [&](int l, int r, int v){ if(r - l <= 1) return l; int m = (l + r) >> 1; if(get(m) <= v) return dfs(m, r, v); else return dfs(l, m, v); } REP(i, n - 1){ int x = dfs(1, l, i); ans.pb(x + (x - ans.back())); } return ans; }

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

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:4:25: error: expected ',' or ';' before 'for'
    4 | #define FOR(i, j, k, l) for(int i = (j); i < (k); i += (l))
      |                         ^~~
routers.cpp:6:19: note: in expansion of macro 'FOR'
    6 | #define REP(i, n) FOR(i, 0, n, 1)
      |                   ^~~
routers.cpp:29:5: note: in expansion of macro 'REP'
   29 |     REP(i, n - 1){
      |     ^~~
routers.cpp:29:9: error: 'i' was not declared in this scope
   29 |     REP(i, n - 1){
      |         ^
routers.cpp:4:42: note: in definition of macro 'FOR'
    4 | #define FOR(i, j, k, l) for(int i = (j); i < (k); i += (l))
      |                                          ^
routers.cpp:29:5: note: in expansion of macro 'REP'
   29 |     REP(i, n - 1){
      |     ^~~