제출 #400068

#제출 시각아이디문제언어결과실행 시간메모리
400068teehandsome다리 (APIO19_bridges)C++11
0 / 100
82 ms97672 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define endl '\n' #define INF 1e9+7 #define all(x) x.begin(),x.end() using namespace std; using namespace __gnu_pbds; using ll=long long; using pii=pair<int,int>; using ppi=pair<int,pii>; using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>; template<typename T> void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";} void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";} template<typename T> void _print(T x) {cerr<<x;} void dbg() {cerr<<endl;} template<typename Head,typename... Tail> void dbg(Head H,Tail... T) { _print(H); if(sizeof...(T)) cerr<<","; else cerr<<"\"]"; dbg(T...); } #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__) //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n,m,q; multiset<int,greater<int>> adj[1010][1010]; ppi idx[1010]; int solve(int s,int mx) { vector<bool> flag(n+1,false); queue<int> q; q.push(s); while(!q.empty()) { int u=q.front(); q.pop(); flag[u]=true; for(int i=1;i<=n;i++) { int U=u,V=i; if(U>V) swap(U,V); if(flag[i] or adj[U][V].empty()) continue; // if(*adj[U][V].begin()<mx) continue; flag[i]=true; q.push(i); } } int ans=0; for(int i=1;i<=n;i++) { if(flag[i]) ans++; } return ans; } int main () { ios::sync_with_stdio(false); cin.tie(0); cin>>n>>m; assert(n<=1000 and m<=1000); for(int i=1;i<=m;i++) { int u,v,w; cin>>u>>v>>w; if(u>v) swap(u,v); adj[u][v].insert(w); idx[i]={w,{u,v}}; } int q; cin>>q; while(q--) { int t,x,y; cin>>t>>x>>y; if(t==1) { ppi temp=idx[x]; int u=temp.second.first; int v=temp.second.second; int w=temp.first; if(u>v) swap(u,v); adj[u][v].erase(adj[u][v].find(w)); adj[u][v].insert(y); temp.first=y; } else { cout<<solve(x,y)<<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...