Submission #588809

# Submission time Handle Problem Language Result Execution time Memory
588809 2022-07-04T05:40:31 Z Red_Inside Sprinkler (JOI22_sprinkler) C++17
9 / 100
389 ms 66496 KB
//
#include <bits/stdc++.h>

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long

using namespace std;
const int maxn=1e6+10,LOG=17, mod=1e9+7;
int block = 320, timer = 0;
const ld EPS = 1e-18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define bt(i) (1 << (i))
#define int ll
const ll inf=1e9+10;
#define y1 yy
#define prev pre
#define pii pair <int, int>

int n, q;
ll L, mem[maxn], h[maxn];
vector <int> edge[maxn], hev[maxn];

main()
{
	IOS
	cin >> n >> L;
	forn(1, i, n - 1)
	{
		int l, r;
		cin >> l >> r;
		edge[l].pb(r);
		edge[r].pb(l);
	}
	forn(1, v, n)
	{
		for(auto to : edge[v])
		{
			if(edge[to].size() > block)
			{
				hev[v].pb(to);
			}
		}
	}
	forn(1, i, n) mem[i] = 1;
	forn(1, i, n) cin >> h[i];
	cin >> q;
	forn(1, i, q)
	{
		int ty;
		cin >> ty;
		if(ty == 1)
		{
			int x, d;
			ll w;
			cin >> x >> d >> w;
			h[x] = h[x] * w % L;
			if(d == 0)
			{
				continue;
			}
			if(edge[x].size() <= block)
			{
				for(auto to : edge[x])
				{
					h[to] = h[to] * w % L;
				}
			}
			else
			{
				mem[x] = mem[x] * w % L;
			}
		}
		else
		{
			int x;
			cin >> x;
			ll ans = h[x];
			for(auto to : hev[x])
			{
				ans = ans * mem[to] % L;
			}
			cout << ans << "\n";
		}
	}
}

Compilation message

sprinkler.cpp:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main()
      | ^~~~
sprinkler.cpp: In function 'int main()':
sprinkler.cpp:51:23: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |    if(edge[to].size() > block)
      |       ~~~~~~~~~~~~~~~~^~~~~~~
sprinkler.cpp:74:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   74 |    if(edge[x].size() <= block)
      |       ~~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 47308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 47196 KB Output is correct
2 Correct 245 ms 61228 KB Output is correct
3 Correct 389 ms 58024 KB Output is correct
4 Correct 247 ms 58604 KB Output is correct
5 Correct 300 ms 59584 KB Output is correct
6 Correct 262 ms 59644 KB Output is correct
7 Correct 317 ms 60108 KB Output is correct
8 Correct 296 ms 66496 KB Output is correct
9 Correct 279 ms 60120 KB Output is correct
10 Correct 305 ms 56984 KB Output is correct
11 Correct 285 ms 61364 KB Output is correct
12 Correct 313 ms 58196 KB Output is correct
13 Correct 265 ms 64352 KB Output is correct
14 Correct 248 ms 64644 KB Output is correct
15 Correct 272 ms 64600 KB Output is correct
16 Correct 263 ms 64544 KB Output is correct
17 Correct 268 ms 65116 KB Output is correct
18 Correct 23 ms 47220 KB Output is correct
19 Correct 22 ms 47280 KB Output is correct
20 Correct 22 ms 47244 KB Output is correct
21 Correct 22 ms 47264 KB Output is correct
22 Correct 24 ms 47212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 47196 KB Output is correct
2 Correct 245 ms 61228 KB Output is correct
3 Correct 389 ms 58024 KB Output is correct
4 Correct 247 ms 58604 KB Output is correct
5 Correct 300 ms 59584 KB Output is correct
6 Correct 262 ms 59644 KB Output is correct
7 Correct 317 ms 60108 KB Output is correct
8 Correct 296 ms 66496 KB Output is correct
9 Correct 279 ms 60120 KB Output is correct
10 Correct 305 ms 56984 KB Output is correct
11 Correct 285 ms 61364 KB Output is correct
12 Correct 313 ms 58196 KB Output is correct
13 Correct 265 ms 64352 KB Output is correct
14 Correct 248 ms 64644 KB Output is correct
15 Correct 272 ms 64600 KB Output is correct
16 Correct 263 ms 64544 KB Output is correct
17 Correct 268 ms 65116 KB Output is correct
18 Correct 23 ms 47220 KB Output is correct
19 Correct 22 ms 47280 KB Output is correct
20 Correct 22 ms 47244 KB Output is correct
21 Correct 22 ms 47264 KB Output is correct
22 Correct 24 ms 47212 KB Output is correct
23 Correct 22 ms 47316 KB Output is correct
24 Incorrect 287 ms 61712 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 47188 KB Output is correct
2 Incorrect 241 ms 59548 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 47244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 47308 KB Output isn't correct
2 Halted 0 ms 0 KB -