Submission #588800

# Submission time Handle Problem Language Result Execution time Memory
588800 2022-07-04T05:30:20 Z Red_Inside Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 36168 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, L, h[maxn];
vector <int> edge[maxn];

void dfs(int v, int d, ll w, int pred = -1)
{
	h[v] = h[v] * w % L;
	if(d == 0) return;
	for(auto to : edge[v])
	{
		if(to == pred) continue;
		dfs(to, d + 1, w, v);
	}
}

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, 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;
			dfs(x, -d, w);
		}
		else
		{
			int x;
			cin >> x;
			cout << h[x] << "\n";
		}
	}
}

Compilation message

sprinkler.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 13 ms 23712 KB Output is correct
4 Correct 16 ms 23860 KB Output is correct
5 Correct 14 ms 23812 KB Output is correct
6 Correct 21 ms 23876 KB Output is correct
7 Correct 18 ms 23824 KB Output is correct
8 Correct 18 ms 23800 KB Output is correct
9 Correct 14 ms 23764 KB Output is correct
10 Correct 16 ms 23788 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 15 ms 23784 KB Output is correct
14 Correct 16 ms 23704 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 13 ms 23704 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 14 ms 23764 KB Output is correct
20 Correct 13 ms 23720 KB Output is correct
21 Correct 14 ms 23784 KB Output is correct
22 Correct 15 ms 23796 KB Output is correct
23 Correct 13 ms 23764 KB Output is correct
24 Correct 12 ms 23764 KB Output is correct
25 Correct 12 ms 23764 KB Output is correct
26 Correct 13 ms 23712 KB Output is correct
27 Correct 12 ms 23768 KB Output is correct
28 Correct 12 ms 23720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23764 KB Output is correct
2 Correct 225 ms 36168 KB Output is correct
3 Correct 318 ms 32964 KB Output is correct
4 Correct 224 ms 33528 KB Output is correct
5 Correct 239 ms 34768 KB Output is correct
6 Correct 243 ms 34604 KB Output is correct
7 Correct 237 ms 35020 KB Output is correct
8 Correct 200 ms 35128 KB Output is correct
9 Correct 223 ms 35020 KB Output is correct
10 Correct 296 ms 31996 KB Output is correct
11 Correct 270 ms 36128 KB Output is correct
12 Correct 319 ms 32980 KB Output is correct
13 Execution timed out 4057 ms 33080 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23764 KB Output is correct
2 Correct 225 ms 36168 KB Output is correct
3 Correct 318 ms 32964 KB Output is correct
4 Correct 224 ms 33528 KB Output is correct
5 Correct 239 ms 34768 KB Output is correct
6 Correct 243 ms 34604 KB Output is correct
7 Correct 237 ms 35020 KB Output is correct
8 Correct 200 ms 35128 KB Output is correct
9 Correct 223 ms 35020 KB Output is correct
10 Correct 296 ms 31996 KB Output is correct
11 Correct 270 ms 36128 KB Output is correct
12 Correct 319 ms 32980 KB Output is correct
13 Execution timed out 4057 ms 33080 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 718 ms 32456 KB Output is correct
3 Execution timed out 4030 ms 31752 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 751 ms 35180 KB Output is correct
3 Execution timed out 4088 ms 31916 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 13 ms 23712 KB Output is correct
4 Correct 16 ms 23860 KB Output is correct
5 Correct 14 ms 23812 KB Output is correct
6 Correct 21 ms 23876 KB Output is correct
7 Correct 18 ms 23824 KB Output is correct
8 Correct 18 ms 23800 KB Output is correct
9 Correct 14 ms 23764 KB Output is correct
10 Correct 16 ms 23788 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 15 ms 23784 KB Output is correct
14 Correct 16 ms 23704 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 13 ms 23704 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 14 ms 23764 KB Output is correct
20 Correct 13 ms 23720 KB Output is correct
21 Correct 14 ms 23784 KB Output is correct
22 Correct 15 ms 23796 KB Output is correct
23 Correct 13 ms 23764 KB Output is correct
24 Correct 12 ms 23764 KB Output is correct
25 Correct 12 ms 23764 KB Output is correct
26 Correct 13 ms 23712 KB Output is correct
27 Correct 12 ms 23768 KB Output is correct
28 Correct 12 ms 23720 KB Output is correct
29 Correct 16 ms 23764 KB Output is correct
30 Correct 225 ms 36168 KB Output is correct
31 Correct 318 ms 32964 KB Output is correct
32 Correct 224 ms 33528 KB Output is correct
33 Correct 239 ms 34768 KB Output is correct
34 Correct 243 ms 34604 KB Output is correct
35 Correct 237 ms 35020 KB Output is correct
36 Correct 200 ms 35128 KB Output is correct
37 Correct 223 ms 35020 KB Output is correct
38 Correct 296 ms 31996 KB Output is correct
39 Correct 270 ms 36128 KB Output is correct
40 Correct 319 ms 32980 KB Output is correct
41 Execution timed out 4057 ms 33080 KB Time limit exceeded
42 Halted 0 ms 0 KB -