이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
using namespace std;
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <utility>
#include <memory.h>
#include <vector>
#include <bitset>
typedef pair<int,int> pii;
typedef long long LL;
#define iter(x) x.begin(),x.end()
#define F first
#define S second
#define pb push_back
#define mkp make_pair
#include <climits>
const int maxn = 1e5+100,mod = 0;
int mp[maxn],val[maxn];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n,q,w;
cin >> n >> q >> w;
multiset <LL> mst;
for (int i=0;i<n-1;++i){
int u,v;
LL c;
cin >> u >> v >> c;
mp[i] = max(u,v);
val[max(u,v)] = c;
mst.insert(c);
}
LL last = 0;
while (q--){
int d; LL e;
cin >> d >> e;
d = (last + d) % (n-1);
e = (last + e) % w;
mst.erase(mst.find(val[mp[d]]));
val[mp[d]] = e;
mst.insert(e);
last = *prev(mst.end()) + (n == 2 ? 0 : *prev(prev(mst.end())));
cout << last << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |