Submission #785585

# Submission time Handle Problem Language Result Execution time Memory
785585 2023-07-17T10:25:46 Z kebine Sprinkler (JOI22_sprinkler) C++17
3 / 100
212 ms 14148 KB
#include<bits/stdc++.h>
 
#define sherina ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define int long long
#define INF 1e18
#define endl '\n'
 
using namespace std;

int n , l , a , b , h[200005] , q , t , x , d , w, dist[20005];
vector < int > adj[200005];
bool vis[200005];
vector <int > v;

void bfs(int s){
   vis[s] = true;
   queue < int > q;
   q.push(s);
   while(!q.empty()){
      int u = q.front(); q.pop();
      v.pb(u);
      for(int j = 0 ; j < adj[u].size() ; j++){
         int i = adj[u][j];
         if(vis[i]) continue;
         if(dist[u] == d) continue;
         dist[i] = dist[u] + 1;
         vis[i] = true;
         q.push(i);
      }
   }
}

signed main(){
   cin >> n >> l;
   for(int i = 1 ; i < n ; i++){
      cin >> a >> b;
      adj[a].pb(b);
      adj[b].pb(a);
   }
   for(int i = 1 ; i <= n ; i++) cin >> h[i];
   cin >> q;
   while(q--){
      cin >> t;
      if(t == 1){
         v.clear();
         cin >> x >> d >> w;
         for(int i = 1 ; i <= n ; i++){
            vis[i] = false;
            dist[i] = 0;
         }
         bfs(x);
         for(int i = 0 ; i < v.size() ; i++){
            h[v[i]] = (h[v[i]] * w) % l;
         }

      }
      else{
         cin >> x;
         cout << h[x] << endl;
      }
   }
}

Compilation message

sprinkler.cpp: In function 'void bfs(long long int)':
sprinkler.cpp:23:25: 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]
   23 |       for(int j = 0 ; j < adj[u].size() ; j++){
      |                       ~~^~~~~~~~~~~~~~~
sprinkler.cpp: In function 'int main()':
sprinkler.cpp:53:28: 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]
   53 |          for(int i = 0 ; i < v.size() ; i++){
      |                          ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 7 ms 5076 KB Output is correct
5 Correct 7 ms 5076 KB Output is correct
6 Correct 12 ms 5076 KB Output is correct
7 Correct 13 ms 5092 KB Output is correct
8 Correct 11 ms 5100 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 4 ms 4948 KB Output is correct
12 Correct 5 ms 4948 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 5 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 5 ms 4948 KB Output is correct
18 Correct 4 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 4 ms 4948 KB Output is correct
24 Correct 3 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 4948 KB Output is correct
27 Correct 4 ms 4948 KB Output is correct
28 Correct 5 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Incorrect 189 ms 14148 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Incorrect 189 ms 14148 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Incorrect 183 ms 13324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Incorrect 212 ms 13264 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 7 ms 5076 KB Output is correct
5 Correct 7 ms 5076 KB Output is correct
6 Correct 12 ms 5076 KB Output is correct
7 Correct 13 ms 5092 KB Output is correct
8 Correct 11 ms 5100 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 4 ms 4948 KB Output is correct
12 Correct 5 ms 4948 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 5 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 5 ms 4948 KB Output is correct
18 Correct 4 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 4 ms 4948 KB Output is correct
24 Correct 3 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 4948 KB Output is correct
27 Correct 4 ms 4948 KB Output is correct
28 Correct 5 ms 4948 KB Output is correct
29 Correct 3 ms 4948 KB Output is correct
30 Incorrect 189 ms 14148 KB Output isn't correct
31 Halted 0 ms 0 KB -