이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)
using namespace std;
ll fp(ll x , ll y)
{
if(y==0)
return 1;
ll z = fp(x,y/2);
if(y&1)
return z*z%mod*x%mod;
else
return z*z%mod;
}
int sqrot(ll x)
{
int l = 0 , r = INT_MAX;
while(l<=r)
{
if(mid*mid>=x)
r=mid-1;
else
l=mid+1;
}
return r+1;
}
ll cel(ll x , ll y)
{
return x/y + bool(x%y);
}
ll n , m;
multiset<pll> adj[50009];
bool vis[1009];
pll ed[100009];
ll val[100009];
ll ans;
void dfs(ll n , ll w)
{
if(vis[n])
return;
vis[n]=1;
ans++;
for(auto it : adj[n])
{
if(it.S>=w)
dfs(it.F,w);
}
}
int main()
{
d3
cin >> n >> m;
for(int i = 1 ; m>=i ; i++)
{
cin >> ed[i].F >> ed[i].S >> val[i];
adj[ed[i].F].in({ed[i].S,val[i]});
adj[ed[i].S].in({ed[i].F,val[i]});
}
ll q;
cin >> q;
while(q--)
{
ll t;
cin >> t;
if(t==1)
{
ll i , w;
cin >> i >> w;
adj[ed[i].F].erase(adj[ed[i].F].find({ed[i].S,val[i]}));
adj[ed[i].S].erase(adj[ed[i].S].find({ed[i].F,val[i]}));
val[i]=w;
adj[ed[i].F].in({ed[i].S,val[i]});
adj[ed[i].S].in({ed[i].F,val[i]});
}
else
{
ll idx , w;
cin >> idx >> w;
memset(vis,0,sizeof(vis));
ans=0;
dfs(idx,w);
cans
}
}
}
# | 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... |