이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, m;
int cont = 0;
int pesos[100005];
bool vis[500004];
struct Puente
{
int v, idx;
};
vector <Puente> ady[1500004];
void ask(int curr, int peso)
{
//vis[curr] = true;
//cout<<curr<<".size "<< ady[curr].size()<<endl;
for (int i = 0; i < ady[curr].size(); i++)
{
//cout<<"ask "<<ady[curr][i].v<<" ";
if (vis[ady[curr][i].v] == false and pesos[ady[curr][i].idx] >= peso)
{
vis[ady[curr][i].v] = true;
//// cout<<"se visita "<<ady[curr][i].v<<endl;
// cout<<"ok"<<endl;
cont ++;
//cout<<"de "<<curr<<" se puede llegar a "<<ady[curr][i].v<<endl;
ask(ady[curr][i].v, peso);
} /*else
{
if (vis[ady[curr][i].v] == true)
{
cout<<ady[curr][i].v<<" ya visitado"<<endl;
}else
{
cout<<ady[curr][i].v<<" no resiste"<<endl;;
}
}*/
}
return;
}
int main()
{
cin>>n>>m;
Puente nuevo1, nuevo2;
int s1, s2, w;
for (int i = 1; i <= m; i++)
{
cin>>s1>>s2>>w;
nuevo1.v = s1;
nuevo1.idx = i;
nuevo2.v = s2;
nuevo2.idx = i;
ady[s1].push_back(nuevo2);
ady[s2].push_back(nuevo1);
pesos[i] = w;
}
int q; cin>>q;
int t, a, b;
for (int i = 0; i < q; i++)
{
cin>>t;
if (t == 1)
{
cin>>a>>b;
pesos[a] = b;
}else
{
cin>>a>>b;
fill(vis, vis + n+3, false);
vis[a] = true;
cont = 1;
ask(a, b);
cout<<cont<<"\n";
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
bridges.cpp: In function 'void ask(int, int)':
bridges.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Puente>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for (int i = 0; i < ady[curr].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... |