Submission #892694

# Submission time Handle Problem Language Result Execution time Memory
892694 2023-12-25T16:55:24 Z fanwen Sprinkler (JOI22_sprinkler) C++17
0 / 100
5 ms 10076 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define ll long long
#define file(name)                  \
    if(fopen(name".inp", "r"))      \
        freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);

const int MAX = 2e5 + 5;
const int MAXD = 41;

int n, L, q, h[MAX];
vector <int> adj[MAX];

int MUL(int &x, int y) {
    x = 1LL * x * y % L;
}

void dfs(int u, int p, int val, int d) {
    MUL(h[u], val);
    if(d <= 0) return;
    for (int v : adj[u]) if(v != p) dfs(v, u, val, d - 1);
}

void you_make_it(void) {
    cin >> n >> L;
    for (int i = 1; i < n; ++i) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i) cin >> h[i];
    cin >> q; while(q--) {
        int type; cin >> type;
        if(type == 1) {
            int u, d, w; cin >> u >> w >> d;
            dfs(u, 0, w, d);
        } else {
            int u; cin >> u; cout << h[u] << '\n';
        }
    }

}

signed main() {

#ifdef LOCAL
    freopen("TASK.inp", "r", stdin);
    freopen("TASK.out", "w", stdout);
#endif
    file("sprinkler");
    auto start_time = chrono::steady_clock::now();

    cin.tie(0), cout.tie(0) -> sync_with_stdio(0);

    you_make_it();

    auto end_time = chrono::steady_clock::now();

    cerr << "\nExecution time : " << chrono::duration_cast <chrono::milliseconds> (end_time - start_time).count() << "[ms]" << endl;

    return (0 ^ 0);
}

// Dream it. Wish it. Do it.

Compilation message

sprinkler.cpp: In function 'int MUL(int&, int)':
sprinkler.cpp:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
   20 | }
      | ^
sprinkler.cpp: In function 'int main()':
sprinkler.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sprinkler.cpp:54:5: note: in expansion of macro 'file'
   54 |     file("sprinkler");
      |     ^~~~
sprinkler.cpp:10:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sprinkler.cpp:54:5: note: in expansion of macro 'file'
   54 |     file("sprinkler");
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 10076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 10076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 10076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 10072 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 10076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 10076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -