Submission #588809

#TimeUsernameProblemLanguageResultExecution timeMemory
588809Red_InsideSprinkler (JOI22_sprinkler)C++17
9 / 100
389 ms66496 KiB
// #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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...