Submission #918279

# Submission time Handle Problem Language Result Execution time Memory
918279 2024-01-29T14:22:26 Z eggx50000 Sprinkler (JOI22_sprinkler) C++14
9 / 100
326 ms 103744 KB
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int n, a, b, jo[200099], q;
ll l, arr[200099], dist[200099][45];
vector <int> vec[200099];
vector <ll> ret;
ll x, y, z, w;

void dfs(int node, int par){
    jo[node] = par;
    for(int &e : vec[node]){
        if(e == par) continue;
        dfs(e, node);
    }

}

int main()
{
    scanf("%d %lld", &n, &l);
    for(int i = 1; i < n; i ++){
        scanf("%d %d", &a, &b);
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    dfs(1, 0);
    for(int i = 1; i <= n; i ++){
        scanf("%lld", arr + i);
    }
    for(int i = 0; i <= n; i ++){
        for(int j = 0; j <= 40; j ++){
            dist[i][j] = 1;
        }
    }
    scanf("%d", &q);
    while(q --){
        scanf("%lld %lld", &x, &y);
        if(x == 1){
            scanf("%lld %lld", &z, &w);
            dist[y][z] = dist[y][z] * w % l;
            if(z == 1) dist[jo[y]][0] = dist[jo[y]][0] * w % l;
        }
        else{
            ll r = arr[y];
            r = r * dist[y][0] % l * dist[jo[y]][1] % l * dist[y][1] % l;

            ret.push_back(r);
        }
    }
    for(ll &e : ret){
        printf("%lld\n", e);
    }
    return 0;
}

Compilation message

sprinkler.cpp: In function 'int main()':
sprinkler.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d %lld", &n, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
sprinkler.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d %d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~
sprinkler.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%lld", arr + i);
      |         ~~~~~^~~~~~~~~~~~~~~~~
sprinkler.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
sprinkler.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%lld %lld", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
sprinkler.cpp:42:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |             scanf("%lld %lld", &z, &w);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 323 ms 90908 KB Output is correct
3 Correct 288 ms 96864 KB Output is correct
4 Correct 326 ms 100704 KB Output is correct
5 Correct 271 ms 97992 KB Output is correct
6 Correct 258 ms 97520 KB Output is correct
7 Correct 263 ms 98240 KB Output is correct
8 Correct 238 ms 98620 KB Output is correct
9 Correct 288 ms 103744 KB Output is correct
10 Correct 309 ms 100948 KB Output is correct
11 Correct 299 ms 99008 KB Output is correct
12 Correct 279 ms 96824 KB Output is correct
13 Correct 216 ms 97476 KB Output is correct
14 Correct 240 ms 97696 KB Output is correct
15 Correct 232 ms 97092 KB Output is correct
16 Correct 218 ms 97620 KB Output is correct
17 Correct 234 ms 97992 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 2 ms 8816 KB Output is correct
21 Correct 2 ms 8836 KB Output is correct
22 Correct 4 ms 8792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 323 ms 90908 KB Output is correct
3 Correct 288 ms 96864 KB Output is correct
4 Correct 326 ms 100704 KB Output is correct
5 Correct 271 ms 97992 KB Output is correct
6 Correct 258 ms 97520 KB Output is correct
7 Correct 263 ms 98240 KB Output is correct
8 Correct 238 ms 98620 KB Output is correct
9 Correct 288 ms 103744 KB Output is correct
10 Correct 309 ms 100948 KB Output is correct
11 Correct 299 ms 99008 KB Output is correct
12 Correct 279 ms 96824 KB Output is correct
13 Correct 216 ms 97476 KB Output is correct
14 Correct 240 ms 97696 KB Output is correct
15 Correct 232 ms 97092 KB Output is correct
16 Correct 218 ms 97620 KB Output is correct
17 Correct 234 ms 97992 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 2 ms 8816 KB Output is correct
21 Correct 2 ms 8836 KB Output is correct
22 Correct 4 ms 8792 KB Output is correct
23 Incorrect 2 ms 8792 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8796 KB Output isn't correct
2 Halted 0 ms 0 KB -