(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1104747

#TimeUsernameProblemLanguageResultExecution timeMemory
1104747Malek1387Dynamic Diameter (CEOI19_diameter)C++14
24 / 100
5067 ms255304 KiB
#include<bits/stdc++.h> #define tizoboz ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define int long long #define itn int #define ss set <int> #define prq priority_queue <int> #define endl '\n' const ll MOD = 1e9 + 7; #define md(x) (((x%MOD)+MOD)%MOD) #define vi vector <int> #define vl vector<ll> #define str string #define mata int32_t #define sz size #define lc id *2 #define rc lc +1 #define SZ(x) (int)x.size() #define mid (l+r)/2 #define cn cin #define ct cout #define sep " " #define F first #define X first #define S second #define Y second using namespace std; typedef pair <int , int> pii; const int maxn = 5e3 + 10; ll N , Q , vis [maxn] , dis [maxn] , W , zzz; vector <ll> g [maxn]; vector < pair <int , itn > > yal; int r[maxn][maxn]; void dfs(int i,int p){ for(auto u:g[i]){ if(p==u){ continue; } dis[u]=dis[i]+r[u][i]; dfs(u,i); } if(dis[i]>dis[zzz]){ zzz=i; } } void solve (){ cn >> N >> Q >> W; for (int i = 1 ; i < N ; i ++){ int x1 , x2 , x3; cn >> x1 >> x2 >> x3; r[x1][x2]=x3; r[x2][x1]=x3; yal.pb({x1,x2}); g[x1].pb(x2); g[x2].pb(x1); } ll lastAns = 0; ll ja = 0; while (Q--){ ll d,e; cin>>d>>e; d= ( d + lastAns) % (N-1); e = ( lastAns + e) % W; ll u = yal[d].F; ll v = yal[d].S; r[v][u] = e; dis[1] = 0 ; r[u][v] = e; zzz=0; dfs(1 ,-1); dis[zzz ] = 0; dfs( zzz, -1); ct << dis[zzz] << endl; lastAns = dis [zzz ]; } } mata main(){ tizoboz; int tt = 1; // cn >> tt; while (tt--){ solve(); } return 0; }

Compilation message (stderr)

diameter.cpp: In function 'void solve()':
diameter.cpp:59:8: warning: unused variable 'ja' [-Wunused-variable]
   59 |     ll ja = 0;
      |        ^~
#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...