#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define pll pair<ll, ll>
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const int N = 50100;
const int M = 100100;
const int oo = 2e9;
queue<int> q;
vector<int> g[N];
int n, m, U[M], V[M], D[M], dst[N];
int main(){
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#else
ios_base::sync_with_stdio(0); cin.tie(0);
#endif // _LOCAL
cin >> n >> m;
for (int i = 0; i < m; i++){
cin >> U[i] >> V[i] >> D[i];
U[i]--; V[i]--;
g[U[i]].PB(i);
g[V[i]].PB(i);
}
int qq; cin >> qq;
for (; qq; qq--){
int tp, l, r; cin >> tp >> l >> r;
if (tp == 1){
D[l - 1] = r;
} else {
l--;
while (sz(q)) q.pop();
fill(dst, dst + n, oo);
q.push(l);
dst[l] = 0;
int ans = 0;
while (sz(q)){
int v = q.front(); q.pop();
ans++;
for (int nm : g[v]){
int u = (U[nm] == v ? V[nm] : U[nm]);
if (dst[u] == oo && D[nm] >= r){
dst[u] = dst[v] + 1;
q.push(u);
}
}
}
cout << ans << '\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1536 KB |
Output is correct |
2 |
Correct |
5 ms |
1536 KB |
Output is correct |
3 |
Correct |
87 ms |
1920 KB |
Output is correct |
4 |
Correct |
9 ms |
1664 KB |
Output is correct |
5 |
Correct |
14 ms |
1664 KB |
Output is correct |
6 |
Correct |
12 ms |
1792 KB |
Output is correct |
7 |
Correct |
17 ms |
1664 KB |
Output is correct |
8 |
Correct |
12 ms |
1792 KB |
Output is correct |
9 |
Correct |
16 ms |
1664 KB |
Output is correct |
10 |
Correct |
11 ms |
1664 KB |
Output is correct |
11 |
Correct |
11 ms |
1664 KB |
Output is correct |
12 |
Correct |
11 ms |
1664 KB |
Output is correct |
13 |
Correct |
16 ms |
1664 KB |
Output is correct |
14 |
Correct |
14 ms |
1664 KB |
Output is correct |
15 |
Correct |
17 ms |
1664 KB |
Output is correct |
16 |
Correct |
13 ms |
1664 KB |
Output is correct |
17 |
Correct |
12 ms |
1664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1081 ms |
6776 KB |
Output is correct |
2 |
Correct |
1079 ms |
6904 KB |
Output is correct |
3 |
Correct |
1074 ms |
6976 KB |
Output is correct |
4 |
Correct |
1242 ms |
6824 KB |
Output is correct |
5 |
Correct |
1289 ms |
6904 KB |
Output is correct |
6 |
Execution timed out |
3057 ms |
5372 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1883 ms |
5660 KB |
Output is correct |
2 |
Execution timed out |
3082 ms |
3768 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3088 ms |
7544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1081 ms |
6776 KB |
Output is correct |
2 |
Correct |
1079 ms |
6904 KB |
Output is correct |
3 |
Correct |
1074 ms |
6976 KB |
Output is correct |
4 |
Correct |
1242 ms |
6824 KB |
Output is correct |
5 |
Correct |
1289 ms |
6904 KB |
Output is correct |
6 |
Execution timed out |
3057 ms |
5372 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1536 KB |
Output is correct |
2 |
Correct |
5 ms |
1536 KB |
Output is correct |
3 |
Correct |
87 ms |
1920 KB |
Output is correct |
4 |
Correct |
9 ms |
1664 KB |
Output is correct |
5 |
Correct |
14 ms |
1664 KB |
Output is correct |
6 |
Correct |
12 ms |
1792 KB |
Output is correct |
7 |
Correct |
17 ms |
1664 KB |
Output is correct |
8 |
Correct |
12 ms |
1792 KB |
Output is correct |
9 |
Correct |
16 ms |
1664 KB |
Output is correct |
10 |
Correct |
11 ms |
1664 KB |
Output is correct |
11 |
Correct |
11 ms |
1664 KB |
Output is correct |
12 |
Correct |
11 ms |
1664 KB |
Output is correct |
13 |
Correct |
16 ms |
1664 KB |
Output is correct |
14 |
Correct |
14 ms |
1664 KB |
Output is correct |
15 |
Correct |
17 ms |
1664 KB |
Output is correct |
16 |
Correct |
13 ms |
1664 KB |
Output is correct |
17 |
Correct |
12 ms |
1664 KB |
Output is correct |
18 |
Correct |
1081 ms |
6776 KB |
Output is correct |
19 |
Correct |
1079 ms |
6904 KB |
Output is correct |
20 |
Correct |
1074 ms |
6976 KB |
Output is correct |
21 |
Correct |
1242 ms |
6824 KB |
Output is correct |
22 |
Correct |
1289 ms |
6904 KB |
Output is correct |
23 |
Execution timed out |
3057 ms |
5372 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |