제출 #934335

#제출 시각아이디문제언어결과실행 시간메모리
934335Rifal다리 (APIO19_bridges)C++14
0 / 100
112 ms860 KiB
#include <bits/stdc++.h> #include <fstream> #define endl '\n' #define mod 1000000007 #define INF 1000000000 #define INF2 2000000000000000000 //#define ll long long ///#define cin fin ///#define cout fout using namespace std; double const EPS = 1e-14; ///ofstream fout("herding.out"); ///ifstream fin("herding.in"); const int N = 1e3 + 2; set<pair<int,int>> v[N]; pair<pair<int,int>,int> pa[N]; bool vis[N]; void sol(int s, int lim) { vis[s] = 1; for(auto i : v[s]) { if(vis[i.first] == 0 && i.second>= lim) { sol(i.first,lim); } } } int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); int n, m; cin >> n >> m; for(int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; pa[i] = {{a,b},c}; v[a].insert({b,c}); v[b].insert({a,c}); } int q; cin >> q; while(q--) { int t, a, b; cin >> t >> a >> b; for(int i = 1; i <= n; i++) vis[i] = 0; if(t == 2) { sol(a,b); int ans = 0; for(int i = 1; i <= n; i++) { if(vis[i] == 1) { ans++; // cout << i << 'd' << endl; } } cout << ans << endl; } else { pair<pair<int,int>,int> cur = pa[a-1]; v[cur.first.first].erase({cur.first.second,cur.second}); v[cur.first.second].erase({cur.first.first,cur.second}); v[cur.first.first].insert({cur.first.second,b}); v[cur.first.second].insert({cur.first.first,b}); pa[a-1].second = b; } } 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...