이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MAX_PONTS=100*1000+1,MAX_SOMMET=50*1000+1;
int nbIles,nbPonts,date,rep,nbReq,typeReq,idPont,nouvPoids,posDep,poidsAuto;
int ponts[MAX_PONTS][3];
vector<int> adja[MAX_SOMMET];
int dv[MAX_SOMMET];
void DFS(int pos) {
if (dv[pos]!=date) {
dv[pos]=date;
rep++;
for (int ivois=0;ivois<adja[pos].size();ivois++) {
if (ponts[adja[pos][ivois]][2]>=poidsAuto) {
DFS(ponts[adja[pos][ivois]][0]);
DFS(ponts[adja[pos][ivois]][1]);
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin>>nbIles>>nbPonts;
for (int i=1;i<=nbPonts;i++) {
cin>>ponts[i][0]>>ponts[i][1]>>ponts[i][2];
adja[ponts[i][0]].push_back(i);
adja[ponts[i][1]].push_back(i);
}
cin>>nbReq;
for (int ireq=1;ireq<=nbReq;ireq++) {
cin>>typeReq;
if (typeReq==1) {
cin>>idPont>>nouvPoids;
ponts[idPont][2]=nouvPoids;
}
else {
cin>>posDep>>poidsAuto;
rep=0;
date=ireq;
DFS(posDep);
cout<<rep<<endl;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
bridges.cpp: In function 'void DFS(int)':
bridges.cpp:14:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int ivois=0;ivois<adja[pos].size();ivois++) {
| ~~~~~^~~~~~~~~~~~~~~~~
# | 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... |