Submission #1007626

# Submission time Handle Problem Language Result Execution time Memory
1007626 2024-06-25T09:30:44 Z modwwe Sprinkler (JOI22_sprinkler) C++17
100 / 100
484 ms 102224 KB
//https://www.instagram.com/_modwwe/
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    int a,b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c, d,e,f;

};
int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int  i,s10,s12;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
///     fin(task),fou(task);
#endif
    NHP;
    /// cin>>s1;
   // modwwe
    phongbeo(),down
}
vector<int> v[400001];
int cha[400001];
int val[400001][42];
void dfs(int x,int y)
{
     cha[x]=y;
      for(auto f:v[x])
        if(f!=y) dfs(f,x);
}
void dfs_upd(int x,int y,int z)
{ if(y==-1||x==0)return;
val[x][y]=(val[x][y]*z)%k;
    dfs_upd(cha[x],y-1,z);
}
void dfs_get(int x)
{
    if(dem==41) return;
if(x==1) {for(int j=dem;j<=40;j++)s2=(s2*val[x][j])%k;return;}
    else
 s2=((s2*val[x][dem])%k*val[x][dem+1])%k;
    dem++;
 dfs_get(cha[x]);
}
void phongbeo()
{
    cin>>n>>k;
for(int i=1;i<n;i++)
     cin>>l>>r,v[l].pb(r),v[r].pb(l);
dfs(1,0);
for(int i=0;i<=n;i++)
    for(int j=0;j<=41;j++)
    val[i][j]=1;
 for(int i=1;i<=n;i++)
 cin>>l,val[i][0]=l;
    cin>>m;
    for(int i=1;i<=m;i++)
    {
       cin>>l;
       if(l==1)
       {
           cin>>l>>r>>s2;
            dfs_upd(l,r,s2);
       }
       else
       { dem=0;
       s2=1;
            cin>>l;
            dfs_get(l);
   cout<<s2,down//<<" "<<dem<<" cucu",down

        }
    }
}
/*
4 7
1 2
2 3
3 4
1
1
1
1
9
2 1
2 2
2 3
2 4
1 4 10 2
2 1
2 2
2 3
2 4

*/

Compilation message

sprinkler.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12888 KB Output is correct
2 Correct 3 ms 12988 KB Output is correct
3 Correct 4 ms 12892 KB Output is correct
4 Correct 3 ms 15196 KB Output is correct
5 Correct 4 ms 15048 KB Output is correct
6 Correct 3 ms 15196 KB Output is correct
7 Correct 4 ms 15196 KB Output is correct
8 Correct 4 ms 15196 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 3 ms 12892 KB Output is correct
12 Correct 4 ms 12892 KB Output is correct
13 Correct 3 ms 12892 KB Output is correct
14 Correct 3 ms 13004 KB Output is correct
15 Correct 3 ms 12892 KB Output is correct
16 Correct 4 ms 12996 KB Output is correct
17 Correct 3 ms 12892 KB Output is correct
18 Correct 3 ms 12892 KB Output is correct
19 Correct 4 ms 12892 KB Output is correct
20 Correct 3 ms 12892 KB Output is correct
21 Correct 3 ms 12892 KB Output is correct
22 Correct 3 ms 12892 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 3 ms 12892 KB Output is correct
25 Correct 3 ms 12892 KB Output is correct
26 Correct 3 ms 12892 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12888 KB Output is correct
2 Correct 338 ms 97908 KB Output is correct
3 Correct 223 ms 98388 KB Output is correct
4 Correct 299 ms 100692 KB Output is correct
5 Correct 263 ms 97984 KB Output is correct
6 Correct 183 ms 97620 KB Output is correct
7 Correct 202 ms 98388 KB Output is correct
8 Correct 157 ms 98584 KB Output is correct
9 Correct 398 ms 101968 KB Output is correct
10 Correct 229 ms 102128 KB Output is correct
11 Correct 328 ms 97740 KB Output is correct
12 Correct 195 ms 98392 KB Output is correct
13 Correct 139 ms 98244 KB Output is correct
14 Correct 143 ms 98744 KB Output is correct
15 Correct 144 ms 98260 KB Output is correct
16 Correct 132 ms 98896 KB Output is correct
17 Correct 141 ms 99244 KB Output is correct
18 Correct 3 ms 12892 KB Output is correct
19 Correct 3 ms 13008 KB Output is correct
20 Correct 3 ms 12892 KB Output is correct
21 Correct 3 ms 12892 KB Output is correct
22 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12888 KB Output is correct
2 Correct 338 ms 97908 KB Output is correct
3 Correct 223 ms 98388 KB Output is correct
4 Correct 299 ms 100692 KB Output is correct
5 Correct 263 ms 97984 KB Output is correct
6 Correct 183 ms 97620 KB Output is correct
7 Correct 202 ms 98388 KB Output is correct
8 Correct 157 ms 98584 KB Output is correct
9 Correct 398 ms 101968 KB Output is correct
10 Correct 229 ms 102128 KB Output is correct
11 Correct 328 ms 97740 KB Output is correct
12 Correct 195 ms 98392 KB Output is correct
13 Correct 139 ms 98244 KB Output is correct
14 Correct 143 ms 98744 KB Output is correct
15 Correct 144 ms 98260 KB Output is correct
16 Correct 132 ms 98896 KB Output is correct
17 Correct 141 ms 99244 KB Output is correct
18 Correct 3 ms 12892 KB Output is correct
19 Correct 3 ms 13008 KB Output is correct
20 Correct 3 ms 12892 KB Output is correct
21 Correct 3 ms 12892 KB Output is correct
22 Correct 3 ms 12892 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 336 ms 97920 KB Output is correct
25 Correct 191 ms 98388 KB Output is correct
26 Correct 314 ms 102224 KB Output is correct
27 Correct 249 ms 98128 KB Output is correct
28 Correct 216 ms 98568 KB Output is correct
29 Correct 202 ms 88148 KB Output is correct
30 Correct 175 ms 96704 KB Output is correct
31 Correct 407 ms 99668 KB Output is correct
32 Correct 232 ms 99936 KB Output is correct
33 Correct 336 ms 92496 KB Output is correct
34 Correct 207 ms 86824 KB Output is correct
35 Correct 3 ms 12888 KB Output is correct
36 Correct 3 ms 12892 KB Output is correct
37 Correct 3 ms 12892 KB Output is correct
38 Correct 3 ms 12892 KB Output is correct
39 Correct 3 ms 12892 KB Output is correct
40 Correct 3 ms 12892 KB Output is correct
41 Correct 3 ms 12892 KB Output is correct
42 Correct 3 ms 12892 KB Output is correct
43 Correct 3 ms 12892 KB Output is correct
44 Correct 3 ms 12888 KB Output is correct
45 Correct 3 ms 13144 KB Output is correct
46 Correct 3 ms 12892 KB Output is correct
47 Correct 3 ms 12892 KB Output is correct
48 Correct 3 ms 12892 KB Output is correct
49 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12888 KB Output is correct
2 Correct 408 ms 91216 KB Output is correct
3 Correct 379 ms 98640 KB Output is correct
4 Correct 331 ms 98388 KB Output is correct
5 Correct 273 ms 95056 KB Output is correct
6 Correct 210 ms 95316 KB Output is correct
7 Correct 201 ms 95316 KB Output is correct
8 Correct 184 ms 95680 KB Output is correct
9 Correct 404 ms 97620 KB Output is correct
10 Correct 412 ms 99152 KB Output is correct
11 Correct 328 ms 94800 KB Output is correct
12 Correct 332 ms 95572 KB Output is correct
13 Correct 194 ms 96596 KB Output is correct
14 Correct 232 ms 97444 KB Output is correct
15 Correct 3 ms 12888 KB Output is correct
16 Correct 3 ms 12996 KB Output is correct
17 Correct 3 ms 12892 KB Output is correct
18 Correct 3 ms 12892 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12980 KB Output is correct
2 Correct 478 ms 96128 KB Output is correct
3 Correct 409 ms 95316 KB Output is correct
4 Correct 364 ms 98640 KB Output is correct
5 Correct 277 ms 96744 KB Output is correct
6 Correct 226 ms 96848 KB Output is correct
7 Correct 222 ms 96592 KB Output is correct
8 Correct 183 ms 96704 KB Output is correct
9 Correct 439 ms 101460 KB Output is correct
10 Correct 415 ms 100000 KB Output is correct
11 Correct 343 ms 97468 KB Output is correct
12 Correct 341 ms 95916 KB Output is correct
13 Correct 204 ms 96592 KB Output is correct
14 Correct 208 ms 97616 KB Output is correct
15 Correct 3 ms 12888 KB Output is correct
16 Correct 3 ms 13004 KB Output is correct
17 Correct 3 ms 13148 KB Output is correct
18 Correct 4 ms 12892 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12888 KB Output is correct
2 Correct 3 ms 12988 KB Output is correct
3 Correct 4 ms 12892 KB Output is correct
4 Correct 3 ms 15196 KB Output is correct
5 Correct 4 ms 15048 KB Output is correct
6 Correct 3 ms 15196 KB Output is correct
7 Correct 4 ms 15196 KB Output is correct
8 Correct 4 ms 15196 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 3 ms 12892 KB Output is correct
12 Correct 4 ms 12892 KB Output is correct
13 Correct 3 ms 12892 KB Output is correct
14 Correct 3 ms 13004 KB Output is correct
15 Correct 3 ms 12892 KB Output is correct
16 Correct 4 ms 12996 KB Output is correct
17 Correct 3 ms 12892 KB Output is correct
18 Correct 3 ms 12892 KB Output is correct
19 Correct 4 ms 12892 KB Output is correct
20 Correct 3 ms 12892 KB Output is correct
21 Correct 3 ms 12892 KB Output is correct
22 Correct 3 ms 12892 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 3 ms 12892 KB Output is correct
25 Correct 3 ms 12892 KB Output is correct
26 Correct 3 ms 12892 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 3 ms 12892 KB Output is correct
29 Correct 3 ms 12888 KB Output is correct
30 Correct 338 ms 97908 KB Output is correct
31 Correct 223 ms 98388 KB Output is correct
32 Correct 299 ms 100692 KB Output is correct
33 Correct 263 ms 97984 KB Output is correct
34 Correct 183 ms 97620 KB Output is correct
35 Correct 202 ms 98388 KB Output is correct
36 Correct 157 ms 98584 KB Output is correct
37 Correct 398 ms 101968 KB Output is correct
38 Correct 229 ms 102128 KB Output is correct
39 Correct 328 ms 97740 KB Output is correct
40 Correct 195 ms 98392 KB Output is correct
41 Correct 139 ms 98244 KB Output is correct
42 Correct 143 ms 98744 KB Output is correct
43 Correct 144 ms 98260 KB Output is correct
44 Correct 132 ms 98896 KB Output is correct
45 Correct 141 ms 99244 KB Output is correct
46 Correct 3 ms 12892 KB Output is correct
47 Correct 3 ms 13008 KB Output is correct
48 Correct 3 ms 12892 KB Output is correct
49 Correct 3 ms 12892 KB Output is correct
50 Correct 3 ms 12892 KB Output is correct
51 Correct 3 ms 12892 KB Output is correct
52 Correct 336 ms 97920 KB Output is correct
53 Correct 191 ms 98388 KB Output is correct
54 Correct 314 ms 102224 KB Output is correct
55 Correct 249 ms 98128 KB Output is correct
56 Correct 216 ms 98568 KB Output is correct
57 Correct 202 ms 88148 KB Output is correct
58 Correct 175 ms 96704 KB Output is correct
59 Correct 407 ms 99668 KB Output is correct
60 Correct 232 ms 99936 KB Output is correct
61 Correct 336 ms 92496 KB Output is correct
62 Correct 207 ms 86824 KB Output is correct
63 Correct 3 ms 12888 KB Output is correct
64 Correct 3 ms 12892 KB Output is correct
65 Correct 3 ms 12892 KB Output is correct
66 Correct 3 ms 12892 KB Output is correct
67 Correct 3 ms 12892 KB Output is correct
68 Correct 3 ms 12892 KB Output is correct
69 Correct 3 ms 12892 KB Output is correct
70 Correct 3 ms 12892 KB Output is correct
71 Correct 3 ms 12892 KB Output is correct
72 Correct 3 ms 12888 KB Output is correct
73 Correct 3 ms 13144 KB Output is correct
74 Correct 3 ms 12892 KB Output is correct
75 Correct 3 ms 12892 KB Output is correct
76 Correct 3 ms 12892 KB Output is correct
77 Correct 3 ms 12892 KB Output is correct
78 Correct 3 ms 12888 KB Output is correct
79 Correct 408 ms 91216 KB Output is correct
80 Correct 379 ms 98640 KB Output is correct
81 Correct 331 ms 98388 KB Output is correct
82 Correct 273 ms 95056 KB Output is correct
83 Correct 210 ms 95316 KB Output is correct
84 Correct 201 ms 95316 KB Output is correct
85 Correct 184 ms 95680 KB Output is correct
86 Correct 404 ms 97620 KB Output is correct
87 Correct 412 ms 99152 KB Output is correct
88 Correct 328 ms 94800 KB Output is correct
89 Correct 332 ms 95572 KB Output is correct
90 Correct 194 ms 96596 KB Output is correct
91 Correct 232 ms 97444 KB Output is correct
92 Correct 3 ms 12888 KB Output is correct
93 Correct 3 ms 12996 KB Output is correct
94 Correct 3 ms 12892 KB Output is correct
95 Correct 3 ms 12892 KB Output is correct
96 Correct 3 ms 12892 KB Output is correct
97 Correct 3 ms 12980 KB Output is correct
98 Correct 478 ms 96128 KB Output is correct
99 Correct 409 ms 95316 KB Output is correct
100 Correct 364 ms 98640 KB Output is correct
101 Correct 277 ms 96744 KB Output is correct
102 Correct 226 ms 96848 KB Output is correct
103 Correct 222 ms 96592 KB Output is correct
104 Correct 183 ms 96704 KB Output is correct
105 Correct 439 ms 101460 KB Output is correct
106 Correct 415 ms 100000 KB Output is correct
107 Correct 343 ms 97468 KB Output is correct
108 Correct 341 ms 95916 KB Output is correct
109 Correct 204 ms 96592 KB Output is correct
110 Correct 208 ms 97616 KB Output is correct
111 Correct 3 ms 12888 KB Output is correct
112 Correct 3 ms 13004 KB Output is correct
113 Correct 3 ms 13148 KB Output is correct
114 Correct 4 ms 12892 KB Output is correct
115 Correct 3 ms 12892 KB Output is correct
116 Correct 354 ms 95696 KB Output is correct
117 Correct 348 ms 98512 KB Output is correct
118 Correct 381 ms 102144 KB Output is correct
119 Correct 320 ms 98132 KB Output is correct
120 Correct 229 ms 97872 KB Output is correct
121 Correct 250 ms 98640 KB Output is correct
122 Correct 192 ms 98748 KB Output is correct
123 Correct 453 ms 101216 KB Output is correct
124 Correct 484 ms 100340 KB Output is correct
125 Correct 357 ms 97220 KB Output is correct
126 Correct 345 ms 98388 KB Output is correct
127 Correct 327 ms 98896 KB Output is correct
128 Correct 215 ms 99412 KB Output is correct
129 Correct 231 ms 100444 KB Output is correct