# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119008 | PagodePaiva | Bridges (APIO19_bridges) | C++17 | 38 ms | 848 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
vector <pair <int, int>> g[N];
array<int, 4> ordem_arestas[N];
int mark[N];
void update(int i, int w){
auto [a, pa, b, pb] = ordem_arestas[i];
g[a][pa].second = w;
g[b][pb].second = w;
return;
}
int con;
void dfs(int v, int w){
if(mark[v]) return;
mark[v] = 1;
con++;
for(auto [x, p] : g[v]){
if(p < w) continue;
dfs(x, w);
}
return;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int n, m, q;
cin >> n >> m;
for(int i = 0;i < m;i++){
int a, b, w;
cin >> a >> b >> w;
ordem_arestas[i+1] = {a, g[a].size(), b, g[b].size()};
g[a].push_back({b, w});
g[b].push_back({a, w});
}
cin >> q;
while(q--){
int t;
cin >> t;
if(t == 2){
int s, w;
cin >> s >> w;
memset(mark, 0, sizeof mark);
con = 0;
dfs(s, w);
cout << con << '\n';
}
else{
int idx, w;
cin >> idx >> w;
update(idx, w);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |