Submission #713531

#TimeUsernameProblemLanguageResultExecution timeMemory
713531bin9638Bridges (APIO19_bridges)C++17
13 / 100
34 ms1004 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define N 10010 #define ii pair<int,int> #define fs first #define sc second #define ld double struct canh { int u,v,L; }edge[N]; struct DSU { int lab[N]; void init() { memset(lab,-1,sizeof(lab)); } int root(int u) { if(lab[u]<0) return u; return(lab[u]=root(lab[u])); } void update(int u,int v) { if((u=root(u))==(v=root(v))) return; if(lab[u]>lab[v]) swap(u,v); lab[u]+=lab[v]; lab[v]=u; } }T; int n,m,q; int main() { #ifdef SKY freopen("A.inp","r",stdin); freopen("A.out","w",stdout); #endif // SKY ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>m; for(int i=1;i<=m;i++) cin>>edge[i].u>>edge[i].v>>edge[i].L; cin>>q; while(q--) { int type; cin>>type; if(type==1) { int id,val; cin>>id>>val; edge[id].L=val; }else { T.init(); int u,val; cin>>u>>val; for(int i=1;i<=m;i++) if(edge[i].L>=val) T.update(edge[i].u,edge[i].v); cout<<-T.lab[T.root(u)]<<"\n"; } } 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...