답안 #798678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798678 2023-07-30T22:50:18 Z yeyso Sprinkler (JOI22_sprinkler) C++14
3 / 100
4000 ms 28552 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n, l; cin >> n >> l;
    vector<vector<long long>> adj(n, vector<long long>());
    long long a, b;
    for(long long i = 0; i < n - 1; i ++){
        cin >> a >> b; a -= 1; b -= 1;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<long long> heights(n, 0);
    long long z;
    for(long long i = 0; i < n; i ++){
        cin >> z;
        heights[i] = z;
    }
    long long queries; cin >> queries;
    long long t;
    long long x, d, w;
    vector<long long> res;
    for(long long i = 0; i < queries; i ++){
        cin >> t;
        if(t == 1){
            cin >> x >> d >> w;
            x -= 1;
            queue<vector<long long>> q;
            q.push({0, x, -1});
            long long node, dist, parent;
            while(!q.empty()){
                node = q.front()[1];
                dist = q.front()[0];
                parent = q.front()[2];
                heights[node] *= w;
                heights[node] %= l;
                
                q.pop();
                for(long long i = 0; i < adj[node].size(); i ++){
                    if(adj[node][i] != parent and dist < d){
                        q.push({dist + 1, adj[node][i], node});
                    }
                }
            }
        } else {
            cin >> x;
            res.push_back(heights[x-1]);
        }
    }
    for(long long i = 0; i < res.size(); i ++){
        cout << res[i] << "\n";
    }
}
/*
g++ -std=gnu++17 -O2 -pipe -static -o joi joi.cpp

4 7
1 2
2 3
3 4
1
1
1
1
11
1 2 1 2
1 1 0 2
2 1
2 2
2 3
2 4
1 4 10 2
2 1
2 2
2 3
2 4
*/

Compilation message

sprinkler.cpp: In function 'int main()':
sprinkler.cpp:39:40: 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]
   39 |                 for(long long i = 0; i < adj[node].size(); i ++){
      |                                      ~~^~~~~~~~~~~~~~~~~~
sprinkler.cpp:50: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]
   50 |     for(long long i = 0; i < res.size(); i ++){
      |                          ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 15 ms 412 KB Output is correct
7 Correct 16 ms 308 KB Output is correct
8 Correct 17 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 362 ms 28552 KB Output is correct
3 Correct 596 ms 26520 KB Output is correct
4 Correct 444 ms 26344 KB Output is correct
5 Correct 444 ms 27580 KB Output is correct
6 Correct 440 ms 27172 KB Output is correct
7 Correct 437 ms 27984 KB Output is correct
8 Execution timed out 4043 ms 20516 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 362 ms 28552 KB Output is correct
3 Correct 596 ms 26520 KB Output is correct
4 Correct 444 ms 26344 KB Output is correct
5 Correct 444 ms 27580 KB Output is correct
6 Correct 440 ms 27172 KB Output is correct
7 Correct 437 ms 27984 KB Output is correct
8 Execution timed out 4043 ms 20516 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 677 ms 17196 KB Output is correct
3 Correct 2907 ms 13544 KB Output is correct
4 Correct 1000 ms 15136 KB Output is correct
5 Execution timed out 4054 ms 16040 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 744 ms 27208 KB Output is correct
3 Correct 2825 ms 23164 KB Output is correct
4 Correct 1180 ms 25044 KB Output is correct
5 Execution timed out 4073 ms 23532 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 15 ms 412 KB Output is correct
7 Correct 16 ms 308 KB Output is correct
8 Correct 17 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 362 ms 28552 KB Output is correct
31 Correct 596 ms 26520 KB Output is correct
32 Correct 444 ms 26344 KB Output is correct
33 Correct 444 ms 27580 KB Output is correct
34 Correct 440 ms 27172 KB Output is correct
35 Correct 437 ms 27984 KB Output is correct
36 Execution timed out 4043 ms 20516 KB Time limit exceeded
37 Halted 0 ms 0 KB -