# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1013376 | 2024-07-03T13:21:27 Z | 8pete8 | Sprinkler (JOI22_sprinkler) | C++17 | 4000 ms | 26192 KB |
#include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<cassert> #include<unordered_map> #include <queue> #include <cstdint> #include<cstring> #include<limits.h> #include<cmath> #include<set> #include<algorithm> #include <iomanip> #include<numeric> #include<bitset> using namespace std; #define ll long long #define f first #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define vi vector<int> #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define ub upper_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize ("03,unroll-lopps") #define int long long using namespace std; const int mod=1e9+7,mxn=2e5+5,inf=1e18,minf=-1e18,lg=30; //#undef int int n,k,m; vector<int>adj[mxn+10]; void setIO(string name){ ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } int h[mxn+10],dist[mxn+10]; void solve(int x,int d,int w){ stack<int>st; queue<int>q; q.push(x); dist[x]=0; while(!q.empty()){ int cur=q.front(); q.pop(); h[cur]=(h[cur]%k*w%k)%k; st.push(cur); for(auto i:adj[cur])if(dist[i]==-1&&dist[cur]+1<=d)dist[i]=dist[cur]+1,q.push(i); } while(!st.empty())dist[st.top()]=-1,st.pop(); } int32_t main(){ fastio cin>>n>>k; for(int i=1;i<=n;i++)dist[i]=-1; for(int i=0;i<n-1;i++){ int a,b;cin>>a>>b; adj[a].pb(b); adj[b].pb(a); } for(int i=1;i<=n;i++)cin>>h[i]; int q;cin>>q; while(q--){ int x;cin>>x; if(x==1){ int a,b,c;cin>>a>>b>>c; solve(a,b,c); } else{ int a;cin>>a; cout<<h[a]<<'\n'; } } } /* 4 7 1 2 2 3 3 4 1 1 1 1 11 1 2 1 2 1 1 0 2 2 1 2 2 2 3 2 4 1 4 10 2 2 1 2 2 2 3 2 4 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8024 KB | Output is correct |
2 | Correct | 2 ms | 8024 KB | Output is correct |
3 | Correct | 1 ms | 8028 KB | Output is correct |
4 | Correct | 2 ms | 8028 KB | Output is correct |
5 | Correct | 4 ms | 8120 KB | Output is correct |
6 | Correct | 6 ms | 8024 KB | Output is correct |
7 | Correct | 6 ms | 8196 KB | Output is correct |
8 | Correct | 5 ms | 8028 KB | Output is correct |
9 | Correct | 2 ms | 8132 KB | Output is correct |
10 | Correct | 3 ms | 8480 KB | Output is correct |
11 | Correct | 2 ms | 8028 KB | Output is correct |
12 | Correct | 2 ms | 8028 KB | Output is correct |
13 | Correct | 3 ms | 8028 KB | Output is correct |
14 | Correct | 2 ms | 8028 KB | Output is correct |
15 | Correct | 2 ms | 8028 KB | Output is correct |
16 | Correct | 2 ms | 8028 KB | Output is correct |
17 | Correct | 2 ms | 8024 KB | Output is correct |
18 | Correct | 2 ms | 8028 KB | Output is correct |
19 | Correct | 2 ms | 8024 KB | Output is correct |
20 | Correct | 2 ms | 8028 KB | Output is correct |
21 | Correct | 2 ms | 7944 KB | Output is correct |
22 | Correct | 2 ms | 8028 KB | Output is correct |
23 | Correct | 2 ms | 8028 KB | Output is correct |
24 | Correct | 2 ms | 8028 KB | Output is correct |
25 | Correct | 2 ms | 8028 KB | Output is correct |
26 | Correct | 2 ms | 8112 KB | Output is correct |
27 | Correct | 2 ms | 8028 KB | Output is correct |
28 | Correct | 2 ms | 8028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8028 KB | Output is correct |
2 | Correct | 145 ms | 25460 KB | Output is correct |
3 | Correct | 225 ms | 25172 KB | Output is correct |
4 | Correct | 163 ms | 24268 KB | Output is correct |
5 | Correct | 212 ms | 25204 KB | Output is correct |
6 | Correct | 157 ms | 25132 KB | Output is correct |
7 | Correct | 175 ms | 25684 KB | Output is correct |
8 | Execution timed out | 4014 ms | 19832 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8028 KB | Output is correct |
2 | Correct | 145 ms | 25460 KB | Output is correct |
3 | Correct | 225 ms | 25172 KB | Output is correct |
4 | Correct | 163 ms | 24268 KB | Output is correct |
5 | Correct | 212 ms | 25204 KB | Output is correct |
6 | Correct | 157 ms | 25132 KB | Output is correct |
7 | Correct | 175 ms | 25684 KB | Output is correct |
8 | Execution timed out | 4014 ms | 19832 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 8024 KB | Output is correct |
2 | Correct | 269 ms | 15404 KB | Output is correct |
3 | Correct | 1482 ms | 24104 KB | Output is correct |
4 | Correct | 536 ms | 23372 KB | Output is correct |
5 | Correct | 2578 ms | 24592 KB | Output is correct |
6 | Execution timed out | 4006 ms | 22024 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8104 KB | Output is correct |
2 | Correct | 292 ms | 22128 KB | Output is correct |
3 | Correct | 1514 ms | 21944 KB | Output is correct |
4 | Correct | 548 ms | 24884 KB | Output is correct |
5 | Correct | 2638 ms | 26192 KB | Output is correct |
6 | Execution timed out | 4066 ms | 22164 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8024 KB | Output is correct |
2 | Correct | 2 ms | 8024 KB | Output is correct |
3 | Correct | 1 ms | 8028 KB | Output is correct |
4 | Correct | 2 ms | 8028 KB | Output is correct |
5 | Correct | 4 ms | 8120 KB | Output is correct |
6 | Correct | 6 ms | 8024 KB | Output is correct |
7 | Correct | 6 ms | 8196 KB | Output is correct |
8 | Correct | 5 ms | 8028 KB | Output is correct |
9 | Correct | 2 ms | 8132 KB | Output is correct |
10 | Correct | 3 ms | 8480 KB | Output is correct |
11 | Correct | 2 ms | 8028 KB | Output is correct |
12 | Correct | 2 ms | 8028 KB | Output is correct |
13 | Correct | 3 ms | 8028 KB | Output is correct |
14 | Correct | 2 ms | 8028 KB | Output is correct |
15 | Correct | 2 ms | 8028 KB | Output is correct |
16 | Correct | 2 ms | 8028 KB | Output is correct |
17 | Correct | 2 ms | 8024 KB | Output is correct |
18 | Correct | 2 ms | 8028 KB | Output is correct |
19 | Correct | 2 ms | 8024 KB | Output is correct |
20 | Correct | 2 ms | 8028 KB | Output is correct |
21 | Correct | 2 ms | 7944 KB | Output is correct |
22 | Correct | 2 ms | 8028 KB | Output is correct |
23 | Correct | 2 ms | 8028 KB | Output is correct |
24 | Correct | 2 ms | 8028 KB | Output is correct |
25 | Correct | 2 ms | 8028 KB | Output is correct |
26 | Correct | 2 ms | 8112 KB | Output is correct |
27 | Correct | 2 ms | 8028 KB | Output is correct |
28 | Correct | 2 ms | 8028 KB | Output is correct |
29 | Correct | 2 ms | 8028 KB | Output is correct |
30 | Correct | 145 ms | 25460 KB | Output is correct |
31 | Correct | 225 ms | 25172 KB | Output is correct |
32 | Correct | 163 ms | 24268 KB | Output is correct |
33 | Correct | 212 ms | 25204 KB | Output is correct |
34 | Correct | 157 ms | 25132 KB | Output is correct |
35 | Correct | 175 ms | 25684 KB | Output is correct |
36 | Execution timed out | 4014 ms | 19832 KB | Time limit exceeded |
37 | Halted | 0 ms | 0 KB | - |