Submission #588802

# Submission time Handle Problem Language Result Execution time Memory
588802 2022-07-04T05:33:55 Z Red_Inside Sprinkler (JOI22_sprinkler) C++17
0 / 100
26 ms 47392 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, w;
			cin >> x >> d >> w;
			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:67:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 |    if(edge[x].size() <= block)
      |       ~~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 47188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 47188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 47188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 47392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 47188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 47188 KB Output isn't correct
2 Halted 0 ms 0 KB -