제출 #896884

#제출 시각아이디문제언어결과실행 시간메모리
896884vjudge1Sprinkler (JOI22_sprinkler)C++17
100 / 100
1051 ms108008 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long #define pb push_back #define ff first #define ss second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> #define ordered_multiset tree<type1, null_type, less_equal<type1>, rb_tree_tag, tree_order_statistics_node_update>; using namespace std; using namespace __gnu_pbds; const int mod = 1e9+7; const double PI = acos(-1.0); const double epsilon = 1e-6; const int N = 2e5+5; vector<int> g[N]; int par[N]; void dfs(int v, int p){ par[v] = p; for(auto to : g[v]){ if(to != p) dfs(to, v); } } void solve(){ int n, l; cin >> n >> l; for(int i = 1; i < n; i++){ int u, v; cin >> u >> v; g[u].pb(v); g[v].pb(u); } vector<vector<int> > dp(n + 1, vector<int>(45, 1)); vector<int> a(n + 1); for(int i = 1; i <= n; i++) cin >> a[i]; dfs(1, 0); int q; cin >> q; while(q--){ int ty; cin >> ty; if(ty == 1){ int x, d, w; cin >> x >> d >> w; while(d and par[x]){ dp[x][d] = dp[x][d] * w % l; dp[x][d - 1] = dp[x][d - 1] * w % l; x = par[x]; d--; } while(d + 1){ dp[x][d] = dp[x][d] * w % l; d--; } }else{ int x; cin >> x; int ans = a[x]; for(int i = 0; i <= 40 and x; i++){ ans = ans * dp[x][i] % l; x = par[x]; } cout << ans << '\n'; } } } main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { solve(); } }

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

sprinkler.cpp:72:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   72 | main(){
      | ^~~~
#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...