이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define S second
#define F first
#define ahah ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 1e6 + 7;
const int MOD = 1e9 + 7;
vector<vector<pair<int, int>>> g(N);
vector<pair<int, int>> number(N);
int x[N], y[N], w[N];
bool used[N];
set<int> st;
void dfs(int v, int weight) {
used[v] = true;
st.insert(v);
for (auto to : g[v]) {
if (!used[to.F] and to.S >= weight) {
dfs(to.F, weight);
}
}
return;
}
signed main() {
ahah
int n, m;
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> x[i] >> y[i] >> w[i];
g[x[i]].pb({y[i], w[i]});
g[y[i]].pb({x[i], w[i]});
number[i] = {g[x[i]].size() - 1, g[y[i]].size() - 1};
}
int q;
cin >> q;
while (q--) {
int t, s, weight;
cin >> t >> s >> weight;
if (t == 1) {
int u = x[s], v = y[s];
g[u][number[s].F].S = weight;
g[v][number[s].S].S = weight;
} else {
st.clear();
for(int i = 0 ; i <= n ; i++){
used[i]=false;
}
dfs(s, weight);
cout << st.size() << "\n";
}
}
}
# | 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... |