Submission #711440

# Submission time Handle Problem Language Result Execution time Memory
711440 2023-03-17T01:42:32 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
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:7:8: error: 'll' was not declared in this scope
    7 | vector<ll> doan[605];
      |        ^~
eastereggs.cpp:7:10: error: template argument 1 is invalid
    7 | vector<ll> doan[605];
      |          ^
eastereggs.cpp:7:10: error: template argument 2 is invalid
eastereggs.cpp:8:1: error: 'll' does not name a type
    8 | ll child[605], ma[605];
      | ^~
eastereggs.cpp:9:1: error: 'll' does not name a type
    9 | ll par[605], head[605];
      | ^~
eastereggs.cpp:10:6: error: variable or field 'dfs' declared void
   10 | void dfs(ll u, ll t)
      |      ^~~
eastereggs.cpp:10:10: error: 'll' was not declared in this scope
   10 | void dfs(ll u, ll t)
      |          ^~
eastereggs.cpp:10:16: error: 'll' was not declared in this scope
   10 | void dfs(ll u, ll t)
      |                ^~
eastereggs.cpp:25:6: error: variable or field 'hld' declared void
   25 | void hld(ll u)
      |      ^~~
eastereggs.cpp:25:10: error: 'll' was not declared in this scope
   25 | void hld(ll u)
      |          ^~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:42:17: error: request for member 'clear' in 'doan[i]', which is of non-class type 'int'
   42 |         doan[i].clear();
      |                 ^~~~~
eastereggs.cpp:50:5: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   50 |     dfs(1, 0);
      |     ^~~
      |     ffs
eastereggs.cpp:51:5: error: 'hld' was not declared in this scope
   51 |     hld(1);
      |     ^~~
eastereggs.cpp:53:5: error: 'll' was not declared in this scope
   53 |     ll pos = 0;
      |     ^~
eastereggs.cpp:55:20: error: request for member 'size' in 'doan[i]', which is of non-class type 'int'
   55 |     if(int(doan[i].size()) > 0)
      |                    ^~~~
eastereggs.cpp:57:24: error: could not convert 'doan[i]' from 'int' to 'std::vector<int>'
   57 |         if(query(doan[i]))
      |                  ~~~~~~^
      |                        |
      |                        int
eastereggs.cpp:59:13: error: 'pos' was not declared in this scope; did you mean 'pow'?
   59 |             pos = i;
      |             ^~~
      |             pow
eastereggs.cpp:64:7: error: expected ';' before 'l'
   64 |     ll l = 0; ll r = int(doan[pos].size())-1;
      |       ^~
      |       ;
eastereggs.cpp:64:17: error: expected ';' before 'r'
   64 |     ll l = 0; ll r = int(doan[pos].size())-1;
      |                 ^~
      |                 ;
eastereggs.cpp:65:11: error: 'l' was not declared in this scope
   65 |     while(l < r)
      |           ^
eastereggs.cpp:65:15: error: 'r' was not declared in this scope
   65 |     while(l < r)
      |               ^
eastereggs.cpp:67:11: error: expected ';' before 'mid'
   67 |         ll mid = (l+r)/2;
      |           ^~~~
      |           ;
eastereggs.cpp:68:27: error: template argument 2 is invalid
   68 |         if(query(vector<ll>(doan[pos].begin(), doan[pos].begin()+mid)))
      |                           ^
eastereggs.cpp:68:34: error: 'pos' was not declared in this scope; did you mean 'pow'?
   68 |         if(query(vector<ll>(doan[pos].begin(), doan[pos].begin()+mid)))
      |                                  ^~~
      |                                  pow
eastereggs.cpp:68:66: error: 'mid' was not declared in this scope
   68 |         if(query(vector<ll>(doan[pos].begin(), doan[pos].begin()+mid)))
      |                                                                  ^~~
eastereggs.cpp:72:17: error: 'pos' was not declared in this scope; did you mean 'pow'?
   72 |     return doan[pos][l];
      |                 ^~~
      |                 pow
eastereggs.cpp:72:22: error: 'l' was not declared in this scope
   72 |     return doan[pos][l];
      |                      ^