답안 #878441

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878441 2023-11-24T11:21:00 Z borisAngelov Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 25248 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 200005;

int n, q;
long long mod;

vector<int> g[maxn];

long long height[maxn];

void dfs(int node, int par, int dep, long long mult)
{
    height[node] = (height[node] * mult) % mod;

    for (int i = 0; i < g[node].size(); ++i)
    {
        if (g[node][i] != par && dep >= 1)
        {
            dfs(g[node][i], node, dep - 1, mult);
        }
    }
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n >> mod;

    for (int i = 1; i <= n - 1; ++i)
    {
        int x, y;
        cin >> x >> y;

        g[x].push_back(y);
        g[y].push_back(x);
    }

    for (int i = 1; i <= n; ++i)
    {
        cin >> height[i];
    }

    cin >> q;

    for (int i = 1; i <= q; ++i)
    {
        int type;
        cin >> type;

        if (type == 1)
        {
            int node, dist, mult;
            cin >> node >> dist >> mult;
            dfs(node, node, dist, mult);
        }
        else
        {
            int node;
            cin >> node;
            cout << height[node] << "\n";
        }
    }

    return 0;
}

Compilation message

sprinkler.cpp: In function 'void dfs(int, int, int, long long int)':
sprinkler.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < g[node].size(); ++i)
      |                     ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6332 KB Output is correct
4 Correct 3 ms 6492 KB Output is correct
5 Correct 4 ms 6492 KB Output is correct
6 Correct 6 ms 6492 KB Output is correct
7 Correct 6 ms 6488 KB Output is correct
8 Correct 6 ms 6620 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 3 ms 6552 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 3 ms 6712 KB Output is correct
16 Correct 3 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6488 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6492 KB Output is correct
27 Correct 2 ms 6488 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 148 ms 24660 KB Output is correct
3 Correct 208 ms 25248 KB Output is correct
4 Correct 184 ms 25124 KB Output is correct
5 Correct 166 ms 24940 KB Output is correct
6 Correct 190 ms 24640 KB Output is correct
7 Correct 173 ms 25172 KB Output is correct
8 Execution timed out 4018 ms 20372 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 148 ms 24660 KB Output is correct
3 Correct 208 ms 25248 KB Output is correct
4 Correct 184 ms 25124 KB Output is correct
5 Correct 166 ms 24940 KB Output is correct
6 Correct 190 ms 24640 KB Output is correct
7 Correct 173 ms 25172 KB Output is correct
8 Execution timed out 4018 ms 20372 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 343 ms 22100 KB Output is correct
3 Correct 1617 ms 22356 KB Output is correct
4 Correct 498 ms 21836 KB Output is correct
5 Correct 2776 ms 21916 KB Output is correct
6 Execution timed out 4011 ms 17764 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 332 ms 24440 KB Output is correct
3 Correct 1652 ms 23156 KB Output is correct
4 Correct 701 ms 23268 KB Output is correct
5 Correct 2609 ms 23740 KB Output is correct
6 Execution timed out 4041 ms 18032 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6332 KB Output is correct
4 Correct 3 ms 6492 KB Output is correct
5 Correct 4 ms 6492 KB Output is correct
6 Correct 6 ms 6492 KB Output is correct
7 Correct 6 ms 6488 KB Output is correct
8 Correct 6 ms 6620 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 3 ms 6552 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 3 ms 6712 KB Output is correct
16 Correct 3 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6488 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6492 KB Output is correct
27 Correct 2 ms 6488 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
29 Correct 2 ms 6492 KB Output is correct
30 Correct 148 ms 24660 KB Output is correct
31 Correct 208 ms 25248 KB Output is correct
32 Correct 184 ms 25124 KB Output is correct
33 Correct 166 ms 24940 KB Output is correct
34 Correct 190 ms 24640 KB Output is correct
35 Correct 173 ms 25172 KB Output is correct
36 Execution timed out 4018 ms 20372 KB Time limit exceeded
37 Halted 0 ms 0 KB -