이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e4 + 2;
vector<pair<int,int> > adj[maxn];
vector<tuple<int,int,int> > edge;
bool vis[maxn];
int dfs(int u,int c){
if(vis[u]){
return 0;
}
vis[u] = true;
int res = 1;
for(auto [v,w] : adj[u]){
if(w >= c){
res += dfs(v,c);
}
}
return res;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin >> n >> m;
for(int i=1;i<=m;i++){
int u,v,w;
cin >> u >> v >> w;
adj[u].emplace_back(v,w);
adj[v].emplace_back(u,w);
edge.emplace_back(u,v,w);
}
int q;
cin >> q;
while(q--){
int t,x,y;
cin >> t >> x >> y;
if(t == 1){
int u = get<0>(edge[x-1]);
int v = get<1>(edge[x-1]);
int w = get<2>(edge[x-1]);
int ux = lower_bound(adj[u].begin(),adj[u].end(),make_pair(v,w))-adj[u].begin();
int vx = lower_bound(adj[v].begin(),adj[v].end(),make_pair(u,w))-adj[v].begin();
edge[x-1] = make_tuple(u,v,y);
adj[u][ux].second = y;
adj[v][vx].second = y;
}else{
memset(vis,false,sizeof(vis));
cout << dfs(x,y) << '\n';
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
bridges.cpp: In function 'int dfs(int, int)':
bridges.cpp:14:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
14 | for(auto [v,w] : adj[u]){
| ^
# | 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... |