이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
int main(){
int n,m,q;
cin>>n>>m;
lld edgelist[m][3];
rep(i,0,m){
rep(j,0,3){
cin>>edgelist[i][j];
if(j<2)edgelist[i][j]--;
}
}
cin>>q;
if(n<=1000 && m<=1000 && q<=10000){
while(q--){
int type;
cin>>type;
if(type==1){
int num;
lld val;
cin>>num>>val;
num--;
edgelist[num][2]=val;
}else{
int start;
lld w;
cin>>start>>w;
start--;
vector<int> nei[n];
bool visited[n];
rep(i,0,n)visited[i]=false;
//cout<<start<<endl;
rep(i,0,m){
if(edgelist[i][2]>=w){
//cout<<edgelist[i][0]<<" "<<edgelist[i][1]<<endl;
nei[edgelist[i][0]].push_back(edgelist[i][1]);
nei[edgelist[i][1]].push_back(edgelist[i][0]);
}
}
queue<int> q;
q.push(start);
visited[start]=true;
while(!q.empty()){
int u=q.front();q.pop();
trav(v,nei[u]){
if(!visited[v]){
visited[v]=true;
q.push(v);
}
}
}
lld ans=0;
rep(i,0,n)ans+=visited[i];
cout<<ans<<endl;
}
}
}
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... |