# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
892196 | 2023-12-25T04:09:28 Z | vjudge1 | Sprinkler (JOI22_sprinkler) | C++17 | 4000 ms | 26568 KB |
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define mpa make_pair #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define bc back() #define ar array #define vll vector<ll> using namespace std;/* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds;*/ template <class _T> bool chmin(_T &x, const _T &y){ if(x>y){ x=y; return true; } return false; } template <class _T> bool chmax(_T &x, const _T &y){ bool flag=false; if (x<y){ x=y;flag|=true; } return flag; } //#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=2e18+7; const ll mod=1e9+7; const ll N=2e5+7; const ld eps=1e-9; vector<vll> g(N); ll h[N]; ll i; ll n,k; void dfs(ll v,ll p,ll w,ll d,ll r){ h[v]*=w; h[v]%=k; if(d==r)return; for(auto i : g[v]){ if(i==p)continue; dfs(i,v,w,d+1,r); } } void solve(){ ll i,q; ll a,b,c; cin>>n>>k; for(i=1;i<n;i++){ cin>>a>>b; g[a].pb(b); g[b].pb(a); } for(i=1;i<=n;i++)cin>>h[i]; cin>>q; ll t; for(i=0;i<q;i++){ cin>>t; if(t==1){ cin>>a>>b>>c; dfs(a,0,c,0,b); }else{ cin>>a; cout<<h[a]<<endl; } } } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; } /* 1 7 1 2 2 3 3 4 4 5 3 6 6 7 2 4 1 5 7 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4956 KB | Output is correct |
2 | Correct | 2 ms | 4956 KB | Output is correct |
3 | Correct | 1 ms | 4952 KB | Output is correct |
4 | Correct | 2 ms | 5212 KB | Output is correct |
5 | Correct | 3 ms | 5212 KB | Output is correct |
6 | Correct | 5 ms | 5212 KB | Output is correct |
7 | Correct | 6 ms | 5244 KB | Output is correct |
8 | Correct | 5 ms | 5212 KB | Output is correct |
9 | Correct | 2 ms | 4956 KB | Output is correct |
10 | Correct | 2 ms | 4956 KB | Output is correct |
11 | Correct | 1 ms | 4956 KB | Output is correct |
12 | Correct | 2 ms | 5172 KB | Output is correct |
13 | Correct | 2 ms | 4956 KB | Output is correct |
14 | Correct | 1 ms | 4956 KB | Output is correct |
15 | Correct | 1 ms | 5208 KB | Output is correct |
16 | Correct | 2 ms | 5180 KB | Output is correct |
17 | Correct | 2 ms | 4952 KB | Output is correct |
18 | Correct | 2 ms | 4952 KB | Output is correct |
19 | Correct | 2 ms | 4956 KB | Output is correct |
20 | Correct | 1 ms | 4956 KB | Output is correct |
21 | Correct | 2 ms | 4956 KB | Output is correct |
22 | Correct | 2 ms | 4956 KB | Output is correct |
23 | Correct | 1 ms | 4952 KB | Output is correct |
24 | Correct | 2 ms | 4956 KB | Output is correct |
25 | Correct | 1 ms | 5180 KB | Output is correct |
26 | Correct | 2 ms | 4956 KB | Output is correct |
27 | Correct | 2 ms | 4956 KB | Output is correct |
28 | Correct | 2 ms | 4956 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 5112 KB | Output is correct |
2 | Correct | 155 ms | 25784 KB | Output is correct |
3 | Correct | 201 ms | 26164 KB | Output is correct |
4 | Correct | 171 ms | 24764 KB | Output is correct |
5 | Correct | 193 ms | 25972 KB | Output is correct |
6 | Correct | 163 ms | 25424 KB | Output is correct |
7 | Correct | 165 ms | 26456 KB | Output is correct |
8 | Correct | 163 ms | 26568 KB | Output is correct |
9 | Correct | 143 ms | 24400 KB | Output is correct |
10 | Correct | 259 ms | 24896 KB | Output is correct |
11 | Correct | 167 ms | 25584 KB | Output is correct |
12 | Correct | 190 ms | 26200 KB | Output is correct |
13 | Execution timed out | 4098 ms | 19000 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 5112 KB | Output is correct |
2 | Correct | 155 ms | 25784 KB | Output is correct |
3 | Correct | 201 ms | 26164 KB | Output is correct |
4 | Correct | 171 ms | 24764 KB | Output is correct |
5 | Correct | 193 ms | 25972 KB | Output is correct |
6 | Correct | 163 ms | 25424 KB | Output is correct |
7 | Correct | 165 ms | 26456 KB | Output is correct |
8 | Correct | 163 ms | 26568 KB | Output is correct |
9 | Correct | 143 ms | 24400 KB | Output is correct |
10 | Correct | 259 ms | 24896 KB | Output is correct |
11 | Correct | 167 ms | 25584 KB | Output is correct |
12 | Correct | 190 ms | 26200 KB | Output is correct |
13 | Execution timed out | 4098 ms | 19000 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4956 KB | Output is correct |
2 | Correct | 338 ms | 21648 KB | Output is correct |
3 | Correct | 1751 ms | 22556 KB | Output is correct |
4 | Correct | 592 ms | 21796 KB | Output is correct |
5 | Correct | 3929 ms | 23068 KB | Output is correct |
6 | Execution timed out | 4026 ms | 18620 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4952 KB | Output is correct |
2 | Correct | 333 ms | 24400 KB | Output is correct |
3 | Correct | 1457 ms | 22956 KB | Output is correct |
4 | Correct | 667 ms | 23380 KB | Output is correct |
5 | Correct | 2889 ms | 24648 KB | Output is correct |
6 | Execution timed out | 4104 ms | 19040 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4956 KB | Output is correct |
2 | Correct | 2 ms | 4956 KB | Output is correct |
3 | Correct | 1 ms | 4952 KB | Output is correct |
4 | Correct | 2 ms | 5212 KB | Output is correct |
5 | Correct | 3 ms | 5212 KB | Output is correct |
6 | Correct | 5 ms | 5212 KB | Output is correct |
7 | Correct | 6 ms | 5244 KB | Output is correct |
8 | Correct | 5 ms | 5212 KB | Output is correct |
9 | Correct | 2 ms | 4956 KB | Output is correct |
10 | Correct | 2 ms | 4956 KB | Output is correct |
11 | Correct | 1 ms | 4956 KB | Output is correct |
12 | Correct | 2 ms | 5172 KB | Output is correct |
13 | Correct | 2 ms | 4956 KB | Output is correct |
14 | Correct | 1 ms | 4956 KB | Output is correct |
15 | Correct | 1 ms | 5208 KB | Output is correct |
16 | Correct | 2 ms | 5180 KB | Output is correct |
17 | Correct | 2 ms | 4952 KB | Output is correct |
18 | Correct | 2 ms | 4952 KB | Output is correct |
19 | Correct | 2 ms | 4956 KB | Output is correct |
20 | Correct | 1 ms | 4956 KB | Output is correct |
21 | Correct | 2 ms | 4956 KB | Output is correct |
22 | Correct | 2 ms | 4956 KB | Output is correct |
23 | Correct | 1 ms | 4952 KB | Output is correct |
24 | Correct | 2 ms | 4956 KB | Output is correct |
25 | Correct | 1 ms | 5180 KB | Output is correct |
26 | Correct | 2 ms | 4956 KB | Output is correct |
27 | Correct | 2 ms | 4956 KB | Output is correct |
28 | Correct | 2 ms | 4956 KB | Output is correct |
29 | Correct | 2 ms | 5112 KB | Output is correct |
30 | Correct | 155 ms | 25784 KB | Output is correct |
31 | Correct | 201 ms | 26164 KB | Output is correct |
32 | Correct | 171 ms | 24764 KB | Output is correct |
33 | Correct | 193 ms | 25972 KB | Output is correct |
34 | Correct | 163 ms | 25424 KB | Output is correct |
35 | Correct | 165 ms | 26456 KB | Output is correct |
36 | Correct | 163 ms | 26568 KB | Output is correct |
37 | Correct | 143 ms | 24400 KB | Output is correct |
38 | Correct | 259 ms | 24896 KB | Output is correct |
39 | Correct | 167 ms | 25584 KB | Output is correct |
40 | Correct | 190 ms | 26200 KB | Output is correct |
41 | Execution timed out | 4098 ms | 19000 KB | Time limit exceeded |
42 | Halted | 0 ms | 0 KB | - |