Submission #618865

#TimeUsernameProblemLanguageResultExecution timeMemory
618865ZaniteDynamic Diameter (CEOI19_diameter)C++17
0 / 100
233 ms6944 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; using Edge = pair<ll, pll>; #define fi first #define se second const int maxN = 1e5 + 5; ll n, q, w; ll id[maxN], dist[maxN]; multiset<ll> dpq; int main() { scanf("%lld %lld %lld", &n, &q, &w); dpq.insert(0); for (ll a, b, c, i = 1; i < n; i++) { scanf("%lld %lld %lld", &a, &b, &c); if (b == 1) swap(a, b); id[i-1] = b; dist[b] = c; dpq.insert(c); } ll last = 0; for (ll d, e, i = 1; i <= q; i++) { scanf("%lld %lld", &d, &e); d = (d + last) % (n - 1); e = (e + last) % w; ll change = id[d]; dpq.erase(dpq.lower_bound(dist[change])); dist[change] = e; dpq.insert(e); auto it = dpq.begin(); last = *it; it++; last += *it; printf("%lld\n", last); } }

Compilation message (stderr)

diameter.cpp: In function 'int main()':
diameter.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%lld %lld %lld", &n, &q, &w);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diameter.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%lld %lld %lld", &a, &b, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diameter.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   scanf("%lld %lld", &d, &e);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...