이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define N 1010
vector<ll> to[N],cost[N];
bool vis[N];
ll cmp;
void dfs(ll x,ll lim){
if(vis[x])return;
vis[x]=1;
cmp++;
for(int i=0;i<to[x].size();i++){
if(cost[x][i]>=lim)dfs(to[x][i],lim);
}
}
ll a[N],b[N],c[N];
int main(){
ll n,m,q;
cin>>n>>m; if(n>1000)return 0;
rep(i,m){
cin>>a[i]>>b[i]>>c[i];
to[a[i]].push_back(b[i]);
cost[a[i]].push_back(c[i]);
to[b[i]].push_back(a[i]);
cost[b[i]].push_back(c[i]);
}
cin>>q;
while(q--){
ll t,x,y;
cin>>t>>x>>y;
if(t==1){
x--;
for(int i=0;i<to[a[x]].size();i++){
if(to[a[x]][i]==b[x]){
cost[a[x]][i]=y;
}
}
}
if(t==2){
for(int i=1;i<=n;i++)vis[i]=0;
cmp=0;
dfs(x,y);
cout<<cmp<<endl;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
bridges.cpp: In function 'void dfs(ll, ll)':
bridges.cpp:21:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<to[x].size();i++){
~^~~~~~~~~~~~~
bridges.cpp: In function 'int main()':
bridges.cpp:42:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<to[a[x]].size();i++){
~^~~~~~~~~~~~~~~~
# | 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... |