Submission #641294

# Submission time Handle Problem Language Result Execution time Memory
641294 2022-09-16T10:11:42 Z Tenis0206 Traffickers (RMI18_traffickers) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

void get_w(int nod, int dad = 0)
{
    w[nod] = 1;
    for(auto it : G[nod])
    {
        if(it==dad)
        {
            continue;
        }
        get_w(it,nod);
        w[nod] += w[it];
        t[it] = nod;
        if(w[it] > w[Max[nod]])
        {
            Max[nod] = it;
        }
    }
}

void get_paths(int nod, int dad = 0, int level = 1)
{
    poz[nod] = (++cnt);
    l[nod] = paths;
    if(G[nod].size()==1 && nod!=1)
    {
        return;
    }
    get_paths(Max[nod],nod,level+1);
    for(auto it : G[nod])
    {
        if(it==dad || it==Max[nod])
        {
            continue;
        }
        ++paths;
        c[paths] = it;
        lvl[paths] = level + 1;
        get_paths(it,nod,level+1);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    get_w(1);
    get_paths(1);
    cin>>k;
    for(int i=1;i<=n;i++)
    {
        int x,y;
        cin>>x>>y;
        add_traficker(x,y);
    }
    cin>>q;
    for(int i=1;i<=q;i++)
    {
        int tip;
        cin>>tip;
        if(tip==1)
        {
            int x,y;
            cin>>x>>y;
            add_traficker(x,y);
        }
        else if(tip==2)
        {
            int x,y;
            cin>>x>>y;
            remove_traficker(x,y);
        }
        else
        {
            int x,y,t1,t2;
            cin>>x>>y>>t1>>t2;
            cout<<query_arb(t2,)
        }
    }
    return 0;
}

Compilation message

traffickers.cpp: In function 'void get_w(int, int)':
traffickers.cpp:7:5: error: 'w' was not declared in this scope
    7 |     w[nod] = 1;
      |     ^
traffickers.cpp:8:19: error: 'G' was not declared in this scope
    8 |     for(auto it : G[nod])
      |                   ^
traffickers.cpp:16:9: error: 't' was not declared in this scope; did you mean 'tm'?
   16 |         t[it] = nod;
      |         ^
      |         tm
traffickers.cpp:17:22: error: 'Max' was not declared in this scope
   17 |         if(w[it] > w[Max[nod]])
      |                      ^~~
traffickers.cpp: In function 'void get_paths(int, int, int)':
traffickers.cpp:26:5: error: 'poz' was not declared in this scope; did you mean 'pow'?
   26 |     poz[nod] = (++cnt);
      |     ^~~
      |     pow
traffickers.cpp:26:19: error: 'cnt' was not declared in this scope; did you mean 'int'?
   26 |     poz[nod] = (++cnt);
      |                   ^~~
      |                   int
traffickers.cpp:27:5: error: 'l' was not declared in this scope
   27 |     l[nod] = paths;
      |     ^
traffickers.cpp:27:14: error: 'paths' was not declared in this scope
   27 |     l[nod] = paths;
      |              ^~~~~
traffickers.cpp:28:8: error: 'G' was not declared in this scope
   28 |     if(G[nod].size()==1 && nod!=1)
      |        ^
traffickers.cpp:32:15: error: 'Max' was not declared in this scope
   32 |     get_paths(Max[nod],nod,level+1);
      |               ^~~
traffickers.cpp:33:19: error: 'G' was not declared in this scope
   33 |     for(auto it : G[nod])
      |                   ^
traffickers.cpp:40:9: error: 'c' was not declared in this scope
   40 |         c[paths] = it;
      |         ^
traffickers.cpp:41:9: error: 'lvl' was not declared in this scope; did you mean 'level'?
   41 |         lvl[paths] = level + 1;
      |         ^~~
      |         level
traffickers.cpp: In function 'int main()':
traffickers.cpp:50:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   50 |     cin>>n;
      |          ^
      |          yn
traffickers.cpp:55:9: error: 'G' was not declared in this scope
   55 |         G[x].push_back(y);
      |         ^
traffickers.cpp:60:10: error: 'k' was not declared in this scope
   60 |     cin>>k;
      |          ^
traffickers.cpp:65:9: error: 'add_traficker' was not declared in this scope
   65 |         add_traficker(x,y);
      |         ^~~~~~~~~~~~~
traffickers.cpp:67:10: error: 'q' was not declared in this scope
   67 |     cin>>q;
      |          ^
traffickers.cpp:76:13: error: 'add_traficker' was not declared in this scope
   76 |             add_traficker(x,y);
      |             ^~~~~~~~~~~~~
traffickers.cpp:82:13: error: 'remove_traficker' was not declared in this scope
   82 |             remove_traficker(x,y);
      |             ^~~~~~~~~~~~~~~~
traffickers.cpp:88:32: error: expected primary-expression before ')' token
   88 |             cout<<query_arb(t2,)
      |                                ^
traffickers.cpp:88:19: error: 'query_arb' was not declared in this scope
   88 |             cout<<query_arb(t2,)
      |                   ^~~~~~~~~