Submission #440463

#TimeUsernameProblemLanguageResultExecution timeMemory
440463KULIKOLDBridges (APIO19_bridges)C++17
13 / 100
61 ms488 KiB
//#pragma GCC optimize ("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' int n,m,q; const int DIM = 1007; struct node{ int u,v,w; } edges[DIM]; int P[DIM]; inline int F(int x){ return x==P[x]?x:P[x] = F(P[x]); } void solve(){ for(int i = 1;i<=m;++i){ cin>>edges[i].u>>edges[i].v>>edges[i].w; } cin>>q; for(int i = 1;i<=q;++i){ int type; cin>>type; if (type==1){ int pos,w; cin>>pos>>w; edges[pos].w = w; continue; } int st,w; cin>>st>>w; for(int j = 1;j<=n;++j) P[j] = j; for(int j = 1;j<=m;++j){ if (edges[j].w>=w) P[F(edges[j].u)] = F(edges[j].v); } int res = 0; for(int j = 1;j<=n;++j) res+=(F(j)==F(st)); cout<<res<<endl; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; if (n<=1000 && m<=1000) solve(); 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...