Submission #786109

#TimeUsernameProblemLanguageResultExecution timeMemory
786109vjudge1Tax Evasion (LMIO19_mokesciai)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; int n, m, cnt, x; int par[18][200005], dep[200005], left[200005], right[200005]; bool b[200005]; vector<int> adjl[200005], que[200005], order; void tour(int x){ order.push_back(x); left[x]=cnt++; for(int i:adjl[x]){ tour(i); } right[x]=cnt; } int anc(int x, int dp){ for(int i=17; i>=0; i--){ if(dp&(1<<i)) x=par[i][x]; } return x; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i=2; i<=n; i++){ cin >> x; par[0][i]=x; dep[i]=dep[x]+1; adjl[x].push_back(i); } for(int i=1; i<18; i++){ for(int j=1; j<=n; j++){ par[i][j]=par[i-1][par[i-1][j]]; } } for(int i=0; i<m; i++){ cin >> x; b[x]=1; } tour(1); for(int i=1; i<=n; i++){ if(b[i]){ int up=anc(i, (dep[i]-1)/2); que[left[up]].push_back(right[up]); } } int res=0, mid, l=0, r=n; while(l<=r){ mid=(l+r)/2; priority_queue<int, vector<int>, greater<int>> pq; bool can=1; for(int i=0; i<n && can; i++){ for(int j:que[i]) pq.push(j); if(dep[order[i]]>=mid && !pq.empty()){ int x=pq.top(); pq.pop(); if(x<=i) can=0; } } if(!pq.empty()) can=0; if(can){ res=mid; l=mid+1; }else{ r=mid-1; } } cout << res+1 << endl; }

Compilation message (stderr)

mokesciai.cpp: In function 'void tour(int)':
mokesciai.cpp:10:2: error: reference to 'left' is ambiguous
   10 |  left[x]=cnt++;
      |  ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mokesciai.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mokesciai.cpp:4:35: note:                 'int left [200005]'
    4 | int par[18][200005], dep[200005], left[200005], right[200005];
      |                                   ^~~~
mokesciai.cpp:14:2: error: reference to 'right' is ambiguous
   14 |  right[x]=cnt;
      |  ^~~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mokesciai.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: candidates are: 'std::ios_base& std::right(std::ios_base&)'
 1014 |   right(ios_base& __base)
      |   ^~~~~
mokesciai.cpp:4:49: note:                 'int right [200005]'
    4 | int par[18][200005], dep[200005], left[200005], right[200005];
      |                                                 ^~~~~
mokesciai.cpp: In function 'int main()':
mokesciai.cpp:49:8: error: reference to 'left' is ambiguous
   49 |    que[left[up]].push_back(right[up]);
      |        ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mokesciai.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mokesciai.cpp:4:35: note:                 'int left [200005]'
    4 | int par[18][200005], dep[200005], left[200005], right[200005];
      |                                   ^~~~
mokesciai.cpp:49:28: error: reference to 'right' is ambiguous
   49 |    que[left[up]].push_back(right[up]);
      |                            ^~~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mokesciai.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: candidates are: 'std::ios_base& std::right(std::ios_base&)'
 1014 |   right(ios_base& __base)
      |   ^~~~~
mokesciai.cpp:4:49: note:                 'int right [200005]'
    4 | int par[18][200005], dep[200005], left[200005], right[200005];
      |                                                 ^~~~~