답안 #588804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
588804 2022-07-04T05:35:16 Z Red_Inside Sprinkler (JOI22_sprinkler) C++17
0 / 100
339 ms 59792 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(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:69:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |    if(edge[x].size() <= block)
      |       ~~~~~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 47188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47228 KB Output is correct
2 Correct 249 ms 59792 KB Output is correct
3 Correct 339 ms 56524 KB Output is correct
4 Incorrect 306 ms 57048 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47228 KB Output is correct
2 Correct 249 ms 59792 KB Output is correct
3 Correct 339 ms 56524 KB Output is correct
4 Incorrect 306 ms 57048 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47256 KB Output is correct
2 Incorrect 260 ms 57880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 47280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 47188 KB Output isn't correct
2 Halted 0 ms 0 KB -