Submission #588805

# Submission time Handle Problem Language Result Execution time Memory
588805 2022-07-04T05:36:44 Z Red_Inside Sprinkler (JOI22_sprinkler) C++17
0 / 100
308 ms 63248 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) 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:73:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |    if(edge[x].size() <= block)
      |       ~~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 47260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 47196 KB Output is correct
2 Correct 292 ms 59708 KB Output is correct
3 Correct 297 ms 56532 KB Output is correct
4 Correct 262 ms 56984 KB Output is correct
5 Correct 275 ms 58072 KB Output is correct
6 Correct 265 ms 58008 KB Output is correct
7 Correct 264 ms 58448 KB Output is correct
8 Incorrect 268 ms 63248 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 47196 KB Output is correct
2 Correct 292 ms 59708 KB Output is correct
3 Correct 297 ms 56532 KB Output is correct
4 Correct 262 ms 56984 KB Output is correct
5 Correct 275 ms 58072 KB Output is correct
6 Correct 265 ms 58008 KB Output is correct
7 Correct 264 ms 58448 KB Output is correct
8 Incorrect 268 ms 63248 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 47284 KB Output is correct
2 Incorrect 308 ms 57940 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 47264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 47260 KB Output isn't correct
2 Halted 0 ms 0 KB -