답안 #785580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785580 2023-07-17T10:23:08 Z TakeMe Sprinkler (JOI22_sprinkler) C++14
9 / 100
239 ms 24800 KB
/* Quick Note :
 * Jangan Mikir Lama - lama, sampahin dulu aja kalo OI
 * Always Try to reset
*/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 2e5 + 5;

ll n, q, l;
ll a[nax], mul[nax], par[nax];
vector<vector<ll>> v(nax);

void find_par(ll idx, ll bfr){
	par[idx] = bfr;
	for(auto it : v[idx]){
		if(it != bfr){
			find_par(it, idx);
		}
	}
}

//void upd_val(ll x, ll d){
	//if(d < 0 || x == 0) return;
	//updRange[x] = max(updRange[x], d);
	//upd_val(par[x], d - 1);
//}

//ll que_val(ll x, ll d){
	//if(x == 0 || d > 45) return 0;
	//if(updRange[x] >= d){
		//return 1;
	//}
	//else{
		//return que_val(par[x], d + 1);
	//}
// }

int main(){ 
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    
    cin >> n >> l;
    for(ll i = 1; i < n; i++){
		ll x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	mul[0] = 1;
    for(ll i = 1; i <= n; i++){
		cin >> a[i];
		mul[i] = 1;
	}
	find_par(1, 0);
	cin >> q;
	while(q--){
		ll tp, x, d, w;
		cin >> tp;
		if(tp == 1){
			cin >> x >> d >> w;
			if(d == 0){
				a[x] *= w;
				a[x] %= l;
			}
			else if(d == 1){
				a[x] *= w;
				a[x] %= l;
				
				mul[x] *= w;
				mul[x] %= l;
				a[par[x]] *= w;
				a[par[x]] %= l;
			}
		}
		else{
			cin >> x;
			ll ans = a[x];
			ans = (ans * mul[par[x]]) % l;
			cout << ans << '\n';
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 179 ms 20824 KB Output is correct
3 Correct 198 ms 17576 KB Output is correct
4 Correct 215 ms 21836 KB Output is correct
5 Correct 194 ms 19208 KB Output is correct
6 Correct 190 ms 19116 KB Output is correct
7 Correct 192 ms 19560 KB Output is correct
8 Correct 184 ms 19756 KB Output is correct
9 Correct 223 ms 24800 KB Output is correct
10 Correct 239 ms 21324 KB Output is correct
11 Correct 204 ms 20556 KB Output is correct
12 Correct 210 ms 17340 KB Output is correct
13 Correct 178 ms 17948 KB Output is correct
14 Correct 219 ms 18120 KB Output is correct
15 Correct 181 ms 18088 KB Output is correct
16 Correct 184 ms 18088 KB Output is correct
17 Correct 194 ms 18648 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 4 ms 5044 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 5044 KB Output is correct
22 Correct 3 ms 5036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 179 ms 20824 KB Output is correct
3 Correct 198 ms 17576 KB Output is correct
4 Correct 215 ms 21836 KB Output is correct
5 Correct 194 ms 19208 KB Output is correct
6 Correct 190 ms 19116 KB Output is correct
7 Correct 192 ms 19560 KB Output is correct
8 Correct 184 ms 19756 KB Output is correct
9 Correct 223 ms 24800 KB Output is correct
10 Correct 239 ms 21324 KB Output is correct
11 Correct 204 ms 20556 KB Output is correct
12 Correct 210 ms 17340 KB Output is correct
13 Correct 178 ms 17948 KB Output is correct
14 Correct 219 ms 18120 KB Output is correct
15 Correct 181 ms 18088 KB Output is correct
16 Correct 184 ms 18088 KB Output is correct
17 Correct 194 ms 18648 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 4 ms 5044 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 5044 KB Output is correct
22 Correct 3 ms 5036 KB Output is correct
23 Incorrect 3 ms 5040 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -