#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){
cin >> x >> d >> w;
h[x] = (h[x] * w) % l;
if(d){
for(int i : adj[x]){
h[i] = (h[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++){
| ~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
891 ms |
17404 KB |
Output is correct |
3 |
Correct |
613 ms |
14160 KB |
Output is correct |
4 |
Correct |
664 ms |
14724 KB |
Output is correct |
5 |
Correct |
661 ms |
15844 KB |
Output is correct |
6 |
Correct |
680 ms |
15820 KB |
Output is correct |
7 |
Correct |
726 ms |
16172 KB |
Output is correct |
8 |
Correct |
720 ms |
16316 KB |
Output is correct |
9 |
Correct |
799 ms |
16296 KB |
Output is correct |
10 |
Correct |
610 ms |
13244 KB |
Output is correct |
11 |
Correct |
804 ms |
17316 KB |
Output is correct |
12 |
Correct |
598 ms |
14216 KB |
Output is correct |
13 |
Execution timed out |
4043 ms |
14188 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
891 ms |
17404 KB |
Output is correct |
3 |
Correct |
613 ms |
14160 KB |
Output is correct |
4 |
Correct |
664 ms |
14724 KB |
Output is correct |
5 |
Correct |
661 ms |
15844 KB |
Output is correct |
6 |
Correct |
680 ms |
15820 KB |
Output is correct |
7 |
Correct |
726 ms |
16172 KB |
Output is correct |
8 |
Correct |
720 ms |
16316 KB |
Output is correct |
9 |
Correct |
799 ms |
16296 KB |
Output is correct |
10 |
Correct |
610 ms |
13244 KB |
Output is correct |
11 |
Correct |
804 ms |
17316 KB |
Output is correct |
12 |
Correct |
598 ms |
14216 KB |
Output is correct |
13 |
Execution timed out |
4043 ms |
14188 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Incorrect |
801 ms |
15620 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |