Submission #785605

# Submission time Handle Problem Language Result Execution time Memory
785605 2023-07-17T10:34:56 Z andecaandeci Sprinkler (JOI22_sprinkler) C++17
0 / 100
4000 ms 366368 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;
         if(!vis[x]){
            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:50:31: 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]
   50 |             for(int i = 0 ; i < v.size() ; i++){
      |                             ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 4062 ms 366368 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -