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;
#define ff first
#define ss second
#define pb push_back
#define sz size()
#define ll long long
#define pii pair <int, int>
const int N = 1e5 + 5;
int l[N], r[N], n, m, jog, w[N];
bool vis[N];
vector <pii> v[N];
void dfs (int x, int y) {
jog++;
vis[x] = 1;
for (pii i : v[x]) {
if (vis[i.ff] or y > i.ss) continue;
dfs (i.ff, y);
}
}
int main () {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// freopen ("input.txt", "r", stdin);
cin >> n >> m;
for (int i = 1; i <= m; ++i) {
cin >> l[i] >> r[i] >> w[i];
}
int q;
cin >> q;
while ( q-- ) {
int typ, l1, r1;
cin >> typ >> l1 >> r1;
if (typ == 2) {
for (int i = 1; i <= m; ++i) {
v[l[i]].pb ({r[i], w[i]});
v[r[i]].pb ({l[i], w[i]});
}
jog = 0;
dfs (l1, r1);
for (int i = 1; i <= n; ++i) {
vis[i] = 0;
v[i].clear();
}
cout << jog << "\n";
}
else {
w[l1] = r1;
}
}
}
# | 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... |