답안 #785585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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++){
      |                          ~~^~~~~~~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -