Submission #266482

#TimeUsernameProblemLanguageResultExecution timeMemory
266482defineBridges (APIO19_bridges)C++17
13 / 100
77 ms640 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,n) for(int i=1;i<n;i++) #define rev(i,n) for(int i=n-1;i>=0;i--) #define all(v) v.begin(),v.end() #define P pair<int,int> #define len(s) (int)s.size() template<class T> inline bool chmin(T &a, T b){ if(a>b){a=b;return true;} return false; } template<class T> inline bool chmax(T &a, T b){ if(a<b){a=b;return true;} return false; } constexpr int mod = 1e9+7; constexpr long long inf = 3e18; int N,M; vector<P>G[1005]; int from[1005],to[1005],idx1[1005],idx2[1005]; bool used[1005]; void dfs(int x,int y){ used[x]=true; for(P i:G[x]){ if(!used[i.first]&&i.second>=y)dfs(i.first,y); } } signed main(){ cin>>N>>M; rep(i,M){ int a,b,c;cin>>a>>b>>c;a--;b--; from[i]=a;idx1[i]=len(G[a]); to[i]=b;idx2[i]=len(G[b]); G[a].push_back({b,c}); G[b].push_back({a,c}); } int Q;cin>>Q; while(Q--){ int type;cin>>type; if(type==1){ int a,b;cin>>a>>b;a--; G[from[a]][idx1[a]].second=b; G[to[a]][idx2[a]].second=b; }else { int a,b;cin>>a>>b;a--; memset(used,0,sizeof(used)); dfs(a,b); int ans=0; rep(i,N)ans+=used[i]; cout<<ans<<endl; } } }
#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...