Submission #1117614

#TimeUsernameProblemLanguageResultExecution timeMemory
1117614vjudge1Paprike (COI18_paprike)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<int>g[100001]; bool visit[100001]; long long val[100001]; int ans=0; long long k,sum; void dfs(int node) { sum+=val[node]; if(sum<=k) { visit[node]=1; for(int go:g[node]) if(!visit[go]) dfs(go); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n>>k; for(int i=1;i<=n;i++) cin>>val[i]; for(int i=0;i<n-1;i++) { int a,b; cin>>a>>b; g[a].push_back(b); g[b].push_back(a); } for(int i=1;i<=n;i++) { if(visit[i]==0) { ans++; dfs(i); sum=0; } } cout<<ans-1; return 0; }

Compilation message (stderr)

paprike.cpp: In function 'void dfs(int)':
paprike.cpp:13:9: error: reference to 'visit' is ambiguous
   13 |         visit[node]=1;
      |         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from paprike.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
paprike.cpp:4:6: note:                 'bool visit [100001]'
    4 | bool visit[100001];
      |      ^~~~~
paprike.cpp:15:13: error: reference to 'visit' is ambiguous
   15 |         if(!visit[go])
      |             ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from paprike.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
paprike.cpp:4:6: note:                 'bool visit [100001]'
    4 | bool visit[100001];
      |      ^~~~~
paprike.cpp: In function 'int main()':
paprike.cpp:37:12: error: reference to 'visit' is ambiguous
   37 |         if(visit[i]==0)
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from paprike.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
paprike.cpp:4:6: note:                 'bool visit [100001]'
    4 | bool visit[100001];
      |      ^~~~~