이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define reu(i, a, b) for(int i = a, _b = b; i <= _b; ++i)
#define red(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int N = 5e4 + 5;
int n, m, q;
int b[N];
vector <ii> adj[N];
int visit[1005];
int bfs(int s, int w){
memset(visit, 0, sizeof visit);
int cnt = 1;
visit[s] = 1;
queue <int> q;
q.push(s);
while(q.size()){
int u = q.front(); q.pop();
for(ii x: adj[u]){
int v = x.fi, id = x.se;
if (b[id] >= w && visit[v] == 0){
cnt++;
visit[v] = 1;
q.push(v);
}
}
}
return cnt;
}
void sub1()
{
cin >> q;
while(q--){
int type;
cin >> type;
if (type == 1){
int x, y;
cin >> x >> y;
b[x] = y;
} else {
int s, w;
cin >> s >> w;
cout << bfs(s, w) << '\n';
}
}
}
int32_t main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("TAITRONG.inp", "r", stdin);
// freopen("TAITRONG.out", "w", stdout);
cin >> n >> m;
reu(i, 1, m){
int u, v, d;
cin >> u >> v >> b[i];
adj[u].push_back({v, i});
adj[v].push_back({u, i});
}
sub1();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
bridges.cpp: In function 'int32_t main()':
bridges.cpp:64:19: warning: unused variable 'd' [-Wunused-variable]
64 | int u, v, d;
| ^
# | 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... |