Submission #280423

# Submission time Handle Problem Language Result Execution time Memory
280423 2020-08-22T18:31:42 Z salma Highway Tolls (IOI18_highway) C++14
Compilation error
0 ms 0 KB
#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


vector<int>ans;
vector<int>w;
ll toll , dp;

void solve(int lo , int hi){

    if(lo == hi){
        w[lo] = 1;
        if(ask(w) > toll)
            ans.push_back(lo);
        w[i] = 0;
        return;
    }

    int md = (lo+hi)/2;
    int ok = 0;

    for(int i = lo ; i<=md ; i++)
        w[i] = 1;
    if(ask(w) > toll)
        ok = 1;
     for(int i = lo ; i<=md ; i++)
        w[i] = 0;
    if(ok) solve(lo , md);
    ok = 0;

     for(int i = md+1 ; i<=hi ; i++)
        w[i] = 1;
    if(ask(w) > toll)
        ok = 1;
     for(int i = md+1 ; i<=hi ; i++)
        w[i] = 0;

    if(ok) solve(md+1 , hi);

    return ;
}


void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
    int M = U.size();

    for (int i = 0; i < M; ++i) {
       w.push_back(0);
    }
    toll = ask(w);
    dp = toll / A;

    solve(0,M-1);

    map<int,int>m;
    for(int i=0;i<dp;i++){
        m[U[ans[i]]]++;
        m[V[ans[i]]]++;
    }
    map<int,int>::iterator it = m.begin();

    int S=-1,T=-1;
    for(; it!=m.end();it++){
        if(it->second == 1){
            if(S == -1)S=it->first;
            else{
                T = it->first;
                break;
            }
        }
    }
  answer(S, T);
}

Compilation message

highway.cpp: In function 'void solve(int, int)':
highway.cpp:17:11: error: 'i' was not declared in this scope; did you mean 'hi'?
   17 |         w[i] = 0;
      |           ^
      |           hi