이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
const ll N = 1005;
bool vis[N];
tuple <ll, ll, ll> brid[N];
vector <vector <ll> > adj(N);
vector <ll> wp[N][N];
ll dfs(ll v, ll w) {
ll ans = 1;
vis[v] = true;
for(auto &u: adj[v]) {
if(vis[u]) continue;
for(auto &x: wp[v][u])
if(w <= x) ans += dfs(u, w);
}
return ans;
}
int main() {
ll n, m, i, v, u, w, q, t, l, r;
cin >> n >> m;
for(i = 0; i < m; i++) {
cin >> v >> u >> w;
v--; u--;
adj[v].pb(u);
adj[u].pb(v);
wp[v][u].pb(w);
wp[u][v].pb(w);
brid[i] = {v, u, wp[v][u].size() - 1};
}
cin >> q;
while(q--) {
cin >> t >> l >> r;
l--;
if(t == 1) {
auto temp = brid[l];
ll x = get <0> (temp);
ll y = get <1> (temp);
ll z = get <2> (temp);
wp[x][y][z] = wp[y][x][z] = r;
}
else {
memset(vis, false, sizeof(vis));
cout << dfs(l, r) << "\n";
}
}
return 0;
}
# | 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... |