Submission #785629

# Submission time Handle Problem Language Result Execution time Memory
785629 2023-07-17T10:54:13 Z kebine Sprinkler (JOI22_sprinkler) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> adj[200005];
bool visit[200005];
int arr[200005];
int n, l;
int proses(int x, int d, int w) {
  queue<pair<int, int>> q;
  vector<int> v;
  arr[x] *= w;
  arr[x] %= l;
  visit[x] = true;
  v.push_back(x);
  for(int i = 0; i < adj[x].size(); i++) {
    visit[adj[x][i]] = true;
    v.push_back(adj[x][i]);
    q.push({adj[x][i], 1});
  }
  if(d > 0) {
    while(q.size() > 0) {
      int a = q.front().first;
      int b = q.front().second;
      arr[a] *= w;
      arr[a] %= l;
      
      if(b < d) {
        for(int i = 0; i < adj[a].size(); i++) {
          if(visit[adj[a][i]] == false) {
            visit[adj[a][i]] = true;
            v.push_back(adj[a][i]);
            q.push({adj[a][i], b + 1});
          }
        }
      }
      q.pop();
      
    }
  }
  for(int i = 0; i < v.size(); i++) {
    visit[v[i]] = false;
  }
  return 0;
}

signed main() {
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  
  cin >> n >> l;
  for(int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for(int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int q;
  cin >> q;
  while(q--) {
    int a, x;
    cin >> a >> x;
    if(a == 2) {
      cout << arr[x] << "\n";
    } else {
      int d, w;
      cin >> d >> w;
      int zzz = proses(x, d, w);
      
      
    }
    
  }
}

Compilation message

sprinkler.cpp: In function 'long long int proses(long long int, long long int, long long int)':
sprinkler.cpp:13:3: error: reference to 'visit' is ambiguous
   13 |   visit[x] = true;
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from sprinkler.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)
      |     ^~~~~
sprinkler.cpp:5:6: note:                 'bool visit [200005]'
    5 | bool visit[200005];
      |      ^~~~~
sprinkler.cpp:15:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i = 0; i < adj[x].size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~
sprinkler.cpp:16:5: error: reference to 'visit' is ambiguous
   16 |     visit[adj[x][i]] = true;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from sprinkler.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)
      |     ^~~~~
sprinkler.cpp:5:6: note:                 'bool visit [200005]'
    5 | bool visit[200005];
      |      ^~~~~
sprinkler.cpp:28:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i = 0; i < adj[a].size(); i++) {
      |                        ~~^~~~~~~~~~~~~~~
sprinkler.cpp:29:14: error: reference to 'visit' is ambiguous
   29 |           if(visit[adj[a][i]] == false) {
      |              ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from sprinkler.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)
      |     ^~~~~
sprinkler.cpp:5:6: note:                 'bool visit [200005]'
    5 | bool visit[200005];
      |      ^~~~~
sprinkler.cpp:30:13: error: reference to 'visit' is ambiguous
   30 |             visit[adj[a][i]] = true;
      |             ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from sprinkler.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)
      |     ^~~~~
sprinkler.cpp:5:6: note:                 'bool visit [200005]'
    5 | bool visit[200005];
      |      ^~~~~
sprinkler.cpp:40:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
sprinkler.cpp:41:5: error: reference to 'visit' is ambiguous
   41 |     visit[v[i]] = false;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from sprinkler.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)
      |     ^~~~~
sprinkler.cpp:5:6: note:                 'bool visit [200005]'
    5 | bool visit[200005];
      |      ^~~~~
sprinkler.cpp: In function 'int main()':
sprinkler.cpp:69:11: warning: unused variable 'zzz' [-Wunused-variable]
   69 |       int zzz = proses(x, d, w);
      |           ^~~