제출 #934370

#제출 시각아이디문제언어결과실행 시간메모리
934370vjudge1다리 (APIO19_bridges)C++17
13 / 100
3092 ms11936 KiB
// Problem: A - Strange Device // Contest: Virtual Judge - 2024-02-27 APIO Simulation // URL: https://vjudge.net/contest/612540#problem/A // Memory Limit: 512 MB // Time Limit: 5000 ms // // Powered by CP Editor (https://cpeditor.org) #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl #define prArr(A,n,t) cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl #define what_is(x) cerr << #x << " is " << x << endl typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef vector<int> vi; const int MAXN = 100010; int from[MAXN], to[MAXN], weg[MAXN]; vector<int> g[MAXN]; void dfs (int src, int bnd, vector<bool> &visited) { visited[src] = true; for (int e : g[src]) { int ot = from[e] + to[e] - src; if (!visited[ot] && bnd <= weg[e]) { dfs(ot, bnd, visited); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, q; cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> from[i] >> to[i] >> weg[i]; g[from[i]].push_back(i); g[to[i]].push_back(i); } cin >> q; while (q--) { int t, a, b; cin >> t >> a >> b; if (t == 1) { weg[a] = b; } else { int src = a, boundary = b; vector<bool> visited(n + 1, false); dfs(src, boundary, visited); int ans = 0; for (int i = 1; i <= n; i++) { if (visited[i]) ans += 1; } cout << ans << endl; } } 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...