# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
295718 | CaroLinda | Bridges (APIO19_bridges) | C++14 | 3077 ms | 7800 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Subtask 4
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimization ("O2")
#define lp(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define debug printf
#define tiii tuple<int,int,int>
#define mkt make_tuple
#define pii pair<int,int>
#define mk make_pair
#define ll long long
#define ff first
#define ss second
const int MAXN = 5e4+10 ;
const int MAXM = 1e5+10 ;
const int inf = 1e9+7 ;
using namespace std ;
struct Edge
{
int j , id ;
Edge(int j = 0 , int id=0):j(j) , id(id) {}
};
int N , M , Q , cnt ;
int W[MAXM] ;
vector<Edge> adj[MAXN] ;
bool vis[MAXN] ;
void dfs(int x, int w)
{
cnt++;
vis[x] = true ;
for(auto e : adj[x] )
{
if( vis[e.j] || W[ e.id ] < w ) continue ;
dfs(e.j, w) ;
}
}
int main()
{
scanf("%d%d", &N , &M ) ;
for(int i = 1 , u , v ; i <= M ; i++ )
{
scanf("%d%d%d", &u, &v, &W[i] ) ;
adj[u].pb( Edge(v,i) ) ;
adj[v].pb( Edge(u,i) ) ;
}
scanf("%d", &Q ) ;
for(int i = 1 ,t, a , b ; i <= Q ; i++ )
{
scanf("%d%d%d", &t, &a, &b ) ;
if(t == 1)
{
W[a] = b ;
continue ;
}
lp(j,1,N+1) vis[j] = false ;
cnt = 0 ;
dfs(a,b) ;
printf("%d\n" , cnt ) ;
}
}
/*
3 4
1 2 5
2 3 2
3 1 4
2 3 8
3
2 1 5
2 2 5
2 3 2
*/
Compilation message (stderr)
# | 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... |