Submission #307093

# Submission time Handle Problem Language Result Execution time Memory
307093 2020-09-27T03:03:56 Z phathnv Finding Routers (IOI20_routers) C++14
Compilation error
0 ms 0 KB
#include "routers.h"
#include <bits/stdc++.h>

using namespace std;

vector <int> find_routers(int l, int n, int q){
    vector <int> res;
    res.push_back(0);
    int cur = 0;

    if (n == 2){
        int mid = 1;
        for(int j = 16; j >= 0; j--){
            if (mid + (1 << j) > l)
                continue;
            if (use_detector(mid + (1 << j)) == i - 1)
                mid += (1 << j);
        }
        res.push_back(2 * mid);
        return res;
    }

    for(int i = 1; i < n; i++){
        int mid = cur + 1;
        while (use_detector(min(l, mid + 64)) == i - 1)
            mid = min(l, mid + 64);

        for(int j = 5; j >= 0; j--){
            if (mid + (1 << j) > l)
                continue;
            if (use_detector(mid + (1 << j)) == i - 1)
                mid += (1 << j);
        }
        int nxt = 2 * mid - cur;
        res.push_back(nxt);
        cur = nxt;
    }
    return res;
}

Compilation message

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:16:49: error: 'i' was not declared in this scope
   16 |             if (use_detector(mid + (1 << j)) == i - 1)
      |                                                 ^