답안 #918278

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918278 2024-01-29T14:16:37 Z eggx50000 Sprinkler (JOI22_sprinkler) C++14
0 / 100
854 ms 100848 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 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);
            while(z >= 0 && y){
                dist[y][z] = dist[y][z] * w % l;
                y = jo[y];
                z --;
            }
        }
        else{
            ll r = arr[y];
            int d = 0;
            for(int j = 0; j <= 40; j ++){
                if(y == 1){
                    for(d; d <= 40; d ++) r = r * dist[y][d] % l;
                    break;
                }
                r = r * dist[y][d] % l * dist[y][d + 1] % l;
                d ++;
                y = jo[y];
            }
            ret.push_back(r);
        }
    }
    for(ll &e : ret){
        printf("%lld\n", e);
    }
    return 0;
}

Compilation message

sprinkler.cpp: In function 'int main()':
sprinkler.cpp:52:25: warning: statement has no effect [-Wunused-value]
   52 |                     for(d; d <= 40; d ++) r = r * dist[y][d] % l;
      |                         ^
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:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
sprinkler.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         scanf("%lld %lld", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
sprinkler.cpp:40:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |             scanf("%lld %lld", &z, &w);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 2 ms 8832 KB Output is correct
3 Correct 2 ms 8796 KB Output is correct
4 Incorrect 3 ms 8796 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Incorrect 514 ms 95968 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Incorrect 514 ms 95968 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Incorrect 854 ms 100848 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8792 KB Output is correct
2 Incorrect 813 ms 98976 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 2 ms 8832 KB Output is correct
3 Correct 2 ms 8796 KB Output is correct
4 Incorrect 3 ms 8796 KB Output isn't correct
5 Halted 0 ms 0 KB -