Submission #918279

#TimeUsernameProblemLanguageResultExecution timeMemory
918279eggx50000Sprinkler (JOI22_sprinkler)C++14
9 / 100
326 ms103744 KiB
#include <iostream> #include <vector> using namespace std; using ll = long long; int n, a, b, jo[200099], q; ll l, arr[200099], dist[200099][45]; vector <int> vec[200099]; vector <ll> ret; ll x, y, z, w; void dfs(int node, int par){ jo[node] = par; for(int &e : vec[node]){ if(e == par) continue; dfs(e, node); } } int main() { scanf("%d %lld", &n, &l); for(int i = 1; i < n; i ++){ scanf("%d %d", &a, &b); vec[a].push_back(b); vec[b].push_back(a); } dfs(1, 0); for(int i = 1; i <= n; i ++){ scanf("%lld", arr + i); } for(int i = 0; i <= n; i ++){ for(int j = 0; j <= 40; j ++){ dist[i][j] = 1; } } scanf("%d", &q); while(q --){ scanf("%lld %lld", &x, &y); if(x == 1){ scanf("%lld %lld", &z, &w); dist[y][z] = dist[y][z] * w % l; if(z == 1) dist[jo[y]][0] = dist[jo[y]][0] * w % l; } else{ ll r = arr[y]; r = r * dist[y][0] % l * dist[jo[y]][1] % l * dist[y][1] % l; ret.push_back(r); } } for(ll &e : ret){ printf("%lld\n", e); } return 0; }

Compilation message (stderr)

sprinkler.cpp: In function 'int main()':
sprinkler.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d %lld", &n, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
sprinkler.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d %d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~
sprinkler.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%lld", arr + i);
      |         ~~~~~^~~~~~~~~~~~~~~~~
sprinkler.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
sprinkler.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%lld %lld", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
sprinkler.cpp:42:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |             scanf("%lld %lld", &z, &w);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...