이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
+----------------------------------------------------------------+
| In the name of Allah, the most Gracious and the most Merciful. |
+----------------------------------------------------------------+
When you are down in your misery
And there is nowhere to run
Remember just remember
You can always run to The One.
When things are down
And you are out of your mind
Remember just remember
Allah is The Kind.
*/
# include <bits/stdc++.h>
# define FILE
using namespace std;
const int N = 5e4 + 100;
int n, m, q, used[N], V[N], U[N], W[N];
vector < vector < int > > gr[N];
vector < vector < int > > queires;
int dfs( int x, int v, int w ){
used[v] = x;
int cnt = 1;
for( auto to: gr[v] ){
if( W[to[1]] >= w && used[to[0]] != x){
cnt += dfs(x, to[0], w);
}
}return cnt;
}
void Subtask1(){
for( int i = 1; i <= q; i ++ ){
if( queires[i-1][0] == 1 ){
W[queires[i-1][1]] = queires[i-1][2];
}
else{
cout << dfs(i, queires[i-1][1], queires[i-1][2]) << endl;
}
}
exit( 0 );
}
int main(){
# ifdef FILEs
freopen( "input.txt", "r", stdin );
freopen( "output.txt", "w", stdout );
# endif
ios_base::sync_with_stdio(false);
cin >> n >> m;
for( int i = 1; i <= m; i ++ ){
cin >> V[i] >> U[i] >> W[i];
gr[V[i]].push_back( {U[i], i} );
gr[U[i]].push_back( {V[i], i} );
}
cin >> q;
for(int i = 1; i <= q; i ++ ){
int t, a, b; cin >> t >> a >> b;
queires.push_back({t,a,b});
}
if( n <= 1000 && m <= 1000 && q <= 10000){
Subtask1();
}
}
# | 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... |