제출 #618975

#제출 시각아이디문제언어결과실행 시간메모리
618975Warinchai_s다리 (APIO19_bridges)C++14
0 / 100
3074 ms14624 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int x,m; cin>>x>>m; int n[m][3]; for(int i=0;i<m;i++){ int a,b,c; cin>>a>>b>>c; n[i][0]=a; n[i][1]=b; n[i][2]=c; } int q; cin>>q; while(q){ int c; cin>>c; if(c==1){ int i; cin>>i; int w; cin>>w; n[i-1][2]=w; }else{ vector<pair<int,int> >v[x+1]; queue<int>q; //cout<<"work"; for(int i=0;i<m;i++){ int f=n[i][0],s=n[i][1],t=n[i][2]; v[f].push_back({s,t}); v[s].push_back({f,t}); } //cout<<"work"; int w,s; cin>>s>>w; int vis[x+1]={}; q.push(s); vis[s]=1; int ans=0; //cout<<"work"; while(!q.empty()){ //cout<<"q:"<<q.front()<<" "; ans++; int node=q.front(); q.pop(); if(v[node][0].second>=w&&vis[v[node][0].first]==0){ //cout<<"v1:"<<v[node][0].first<<" "; vis[v[node][0].first]=1; q.push(v[node][0].first); } if(v[node][1].second>=w&&vis[v[node][1].first]==0&&v[node].size()==2){ //cout<<"v2:"<<v[node][1].first<<" "; vis[v[node][1].first]=1; q.push(v[node][1].first); } } cout<<ans<<endl; } q--; } } /* 4 3 1 2 3 2 4 4 3 4 4 3 */
#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...