제출 #1300121

#제출 시각아이디문제언어결과실행 시간메모리
1300121TrieTrSprinkler (JOI22_sprinkler)C++20
3 / 100
4094 ms22076 KiB
#include<bits/stdc++.h> using namespace std; void local() { #define taskname "" if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } } #define ll long long #define fi first #define se second #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;} template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;} const int N = 1e6 + 5; int n, l, q, h[N]; vector<int> adj[N]; tuple<int, int, int, int> que[N]; namespace sub1 { bool check() { return max(n, q) <= 1e3; } void dfs(int u, int p, int d, int bound, int w) { h[u] = 1ll * h[u] * w % l; if(d == bound) return; for(int& v : adj[u]) { if(v == p) continue; dfs(v, u, d + 1, bound, w); } } void solve() { for(int _ = 1; _ <= q; _++) { int t, x, d, w; tie(t, x, d, w) = que[_]; if(t == 1) { dfs(x, x, 0, d, w); } else { cout << h[x] << '\n'; } } } } int main() { fastio; local(); cin >> n >> l; for(int i = 1; i < n; i++) { int u, v; cin >> u >> v; adj[u].emplace_back(v); adj[v].emplace_back(u); } for(int i = 1; i <= n; i++) cin >> h[i]; cin >> q; for(int i = 1; i <= q; i++) { int t, x, d, w; cin >> t >> x; d = 0; w = 0; if(t == 1) cin >> d >> w; que[i] = make_tuple(t, x, d, w); } sub1::solve(); }

컴파일 시 표준 에러 (stderr) 메시지

sprinkler.cpp: In function 'void local()':
sprinkler.cpp:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
sprinkler.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...