제출 #440368

#제출 시각아이디문제언어결과실행 시간메모리
440368VladM다리 (APIO19_bridges)C++14
13 / 100
54 ms588 KiB
#include <bits/stdc++.h> using namespace std; #define DIM 1007 typedef pair<long long, long long> pll; long long vis[DIM], n, m, u, v, w[DIM], q, t, it, r, s, W, res; vector<pll> vec[DIM]; void dfs(long long v, long long car) { vis[v]=1; for(auto to : vec[v]) { if(vis[to.first]==1 || w[to.second]<car) continue; dfs(to.first, car); } return; } int main() { cin>>n>>m; for(int i=1; i<=m; i++) { cin>>u>>v>>w[i]; vec[u].push_back({v, i}); vec[v].push_back({u, i}); } cin>>q; while(q--) { cin>>t; if(t==1) { cin>>it>>r; w[it]=r; continue; } cin>>s>>W; for(int i=1; i<=n; i++) vis[i]=0; vis[s]=1; dfs(s, W); res=0; for(int i=1; i<=n; i++) res+=vis[i]; cout<<res<<endl; } return 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...