이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 50050
#define f first
#define s second
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
vector<multiset<pair<int,int> > > adj(maxn);
int n,m,q;
int input1,input2,input3;
vector<pair<int,pair<int,int> > > edges;
cin >> n >> m;
for(int i=0;i<m;i++){
cin >> input1 >> input2 >> input3;
edges.push_back({input1,{input2,input3}});
adj[input1].insert({input2,input3});
adj[input2].insert({input1,input3});
}
cin >> q;
for(int i=0;i<q;i++){
cin >> input1 >> input2 >> input3;
if(input1==1){//update
input2--;
auto k = adj[edges[input2].f].find({edges[input2].s.f,edges[input2].s.s});
auto j = adj[edges[input2].s.f].find({edges[input2].f,edges[input2].s.s});
adj[edges[input2].f].erase(k);
adj[edges[input2].s.f].erase(j);
edges[input2].s.s = input3;
adj[edges[input2].s.f].insert({edges[input2].f,edges[input2].s.s});
adj[edges[input2].f].insert({edges[input2].s.f,edges[input2].s.s});
}
else{
vector<int> visited(maxn,0);
deque<int> q1;
q1.push_back(input2);
visited[input2] = 1;
while(q1.size()!=0){
int a = q1.front();
q1.pop_front();
for(auto k:adj[a]){
if(k.s<input3){
continue;
}
//cout << k.s << " " << input2 << "--\n";
if(visited[k.f]==0){
visited[k.f] = 1;
q1.push_back(k.f);
}
}
}
int ans = 0;
for(auto k:visited){
ans += k;
}
cout << ans << "\n";
}
//cout << i << "--" << endl;
}
}
# | 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... |