Submission #588850

# Submission time Handle Problem Language Result Execution time Memory
588850 2022-07-04T06:33:37 Z Tekor Sprinkler (JOI22_sprinkler) C++17
9 / 100
308 ms 39004 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second
#define pii pair <int,int>
#define en '\n'
void boos() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int N = 4e5 + 100;
const int bl = 400;
vector <int> g[N],tt[N];
ll a[N],d[N][2],L;
int n;
/*
4 7
1 2
2 3
3 4
1
1
1
1
6
1 2 1 2
1 1 0 2
2 1
2 2
2 3
2 4
*/
void solve() {
	cin >> n >> L;
	for(int i = 1;i <= n;i++) {
		d[i][0] = 1;
		d[i][1] = 1;
	}
	for(int i = 1;i < n;i++) {
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	for(int i = 1;i <= n;i++) {
		for(auto to : g[i]) {
			if(g[to].size() > bl)tt[i].pb(to);
		}
	}
	for(int i = 1;i <= n;i++)cin >> a[i];
	int q;
	cin >> q;
	for(int i = 1;i <= q;i++) {
		int typ;
		cin >> typ;
		if(typ == 1) {
			int x,dist;
			ll w;
			cin >> x >> dist >> w;
			a[x] = (a[x] * w) % L;
			if(dist == 0)continue;
			if(g[x].size() <= bl) {
				for(auto to : g[x]) {
					a[to] = (a[to] * w) % L;
				}
			}else {
				d[x][1] = (d[x][1] * w) % L;
			}
		}else {
			int x;
			cin >> x;
			ll ans = a[x];
			for(auto to : tt[x]) {
				ans = (ans * d[to][1]) % L;
			}
			cout << ans << en;
		}
	}
}

int main() {
	boos();
	int ttt;
	ttt = 1;
	while(ttt--) {
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 19028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 19156 KB Output is correct
2 Correct 237 ms 33680 KB Output is correct
3 Correct 296 ms 30468 KB Output is correct
4 Correct 256 ms 31956 KB Output is correct
5 Correct 277 ms 32044 KB Output is correct
6 Correct 289 ms 32076 KB Output is correct
7 Correct 292 ms 32384 KB Output is correct
8 Correct 256 ms 39004 KB Output is correct
9 Correct 253 ms 33496 KB Output is correct
10 Correct 303 ms 30480 KB Output is correct
11 Correct 230 ms 33612 KB Output is correct
12 Correct 308 ms 30408 KB Output is correct
13 Correct 223 ms 36720 KB Output is correct
14 Correct 247 ms 36828 KB Output is correct
15 Correct 234 ms 36812 KB Output is correct
16 Correct 242 ms 36672 KB Output is correct
17 Correct 256 ms 37296 KB Output is correct
18 Correct 10 ms 19084 KB Output is correct
19 Correct 11 ms 19064 KB Output is correct
20 Correct 12 ms 19028 KB Output is correct
21 Correct 10 ms 19028 KB Output is correct
22 Correct 10 ms 19028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 19156 KB Output is correct
2 Correct 237 ms 33680 KB Output is correct
3 Correct 296 ms 30468 KB Output is correct
4 Correct 256 ms 31956 KB Output is correct
5 Correct 277 ms 32044 KB Output is correct
6 Correct 289 ms 32076 KB Output is correct
7 Correct 292 ms 32384 KB Output is correct
8 Correct 256 ms 39004 KB Output is correct
9 Correct 253 ms 33496 KB Output is correct
10 Correct 303 ms 30480 KB Output is correct
11 Correct 230 ms 33612 KB Output is correct
12 Correct 308 ms 30408 KB Output is correct
13 Correct 223 ms 36720 KB Output is correct
14 Correct 247 ms 36828 KB Output is correct
15 Correct 234 ms 36812 KB Output is correct
16 Correct 242 ms 36672 KB Output is correct
17 Correct 256 ms 37296 KB Output is correct
18 Correct 10 ms 19084 KB Output is correct
19 Correct 11 ms 19064 KB Output is correct
20 Correct 12 ms 19028 KB Output is correct
21 Correct 10 ms 19028 KB Output is correct
22 Correct 10 ms 19028 KB Output is correct
23 Correct 9 ms 19048 KB Output is correct
24 Incorrect 250 ms 33708 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 19028 KB Output is correct
2 Incorrect 255 ms 32872 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 19028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 19028 KB Output isn't correct
2 Halted 0 ms 0 KB -