Submission #784169

# Submission time Handle Problem Language Result Execution time Memory
784169 2023-07-15T19:57:35 Z Ozy Highway Tolls (IOI18_highway) C++17
0 / 100
16 ms 7676 KB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli>

#define MAX 90000
//para los hijos
#define des first
#define id second

lli m,df,prof;
lli arista_padre[MAX+2];
vector<pll> hijos[MAX+2];
vector<lli> nodos;

void dfs(lli pos, lli padre, lli p) {

    if(p == prof) {
        nodos.push_back(pos);
        return;
    }

    for(auto h : hijos[pos]) {
        if(padre == h.des) continue;
        arista_padre[h.des] = h.id;
        dfs(h.des,pos,p+1);
    }
}

void find_pair(int n, std::vector<int> u, std::vector<int> v, int A, int B) {

    m = u.size();
    rep(i,0,m-1) {
        hijos[u[i]].push_back({v[i],i});
        hijos[v[i]].push_back({u[i],i});
    }

    vector<int> status;
    status.resize(m);
    rep(i,0,m-1) status[i] = 0;

    df = ask(status);
    prof = df/A;
    dfs(0,-1,0);

    lli last,ini = 0;
    lli mitad,fin = nodos.size()-1;
    while (ini <= fin) {
        mitad = (ini+fin)/2;
        rep(i,0,nodos.size()-1) {
            if (ini <= i && i <= mitad) status[ arista_padre[nodos[i]] ] = 1;
            else status[i] = 0;
        }

        lli x = ask(status);
        if (x != df) {
            fin = mitad-1;
            last = mitad;
        }
        else ini = mitad+1;
    }

    answer(0,nodos[last]);
}

Compilation message

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:7:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
highway.cpp:55:9: note: in expansion of macro 'rep'
   55 |         rep(i,0,nodos.size()-1) {
      |         ^~~
highway.cpp:68:24: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
   68 |     answer(0,nodos[last]);
      |                        ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2384 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3024 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2496 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 7676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 3280 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -