Submission #711441

# Submission time Handle Problem Language Result Execution time Memory
711441 2023-03-17T01:43:21 Z ooo Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define fi first
#define se second
#define ll long long 
vector< vector<int> > g;
vector<ll> doan[605];
ll child[605], ma[605];
ll par[605], head[605];
void dfs(ll u, ll t)
{
    for(int i = 0; i < int(g[u].size()); ++i)
    {
        ll v = g[u][i];
        if(v == t) continue;
        par[v] = u;
        dfs(v, u);
        if(child[v]+1 > child[u])
        {
            child[u] = child[v]+1;
            ma[u] = v;
        }
    }
}
void hld(ll u)
{
    if(ma[par[u]] == u) head[u] = head[par[u]];
    else head[u] = u;

    doan[head[u]].push_back(u);
    if(ma[u] > 0) hld(ma[u]);
    for(int i = 0; i < int(g[u].size()); ++i)
    {
        ll v = g[u][i];
        if(v != par[u] && v != ma[u]) hld(v);
    }
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
    g.clear();
    for(int i = 1; i <= 600; ++i)
        doan[i].clear();
    g.resize(n+1);
    for(int i = 0; i < int(bridges.size()); ++i)
    {
        g[bridges[i].fi].push_back(bridges[i].se);
        g[bridges[i].se].push_back(bridges[i].fi);
    }

    dfs(1, 0);
    hld(1);

    ll pos = 0;
    for(int i = 1; i <= n; ++i)
    if(int(doan[i].size()) > 0)
    {
        if(query(doan[i]))
        {
            pos = i;
            break;
        }
    }

    ll l = 0; ll r = int(doan[pos].size())-1;
    while(l < r)
    {
        ll mid = (l+r)/2;
        if(query(vector<ll>(doan[pos].begin(), doan[pos].begin()+mid)))
            r = mid;
        else l = mid+1;
    }
    return doan[pos][l];
    return 0;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:58:24: error: could not convert 'doan[i]' from 'vector<long long int>' to 'vector<int>'
   58 |         if(query(doan[i]))
      |                  ~~~~~~^
      |                        |
      |                        vector<long long int>
eastereggs.cpp:69:18: error: could not convert 'std::vector<long long int>(doan[pos].std::vector<long long int>::begin(), doan[pos].std::vector<long long int>::begin().__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::operator+(((__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)mid)), std::allocator<long long int>())' from 'vector<long long int>' to 'vector<int>'
   69 |         if(query(vector<ll>(doan[pos].begin(), doan[pos].begin()+mid)))
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  |
      |                  vector<long long int>