선생님 안녕하세요. 다른 풀이에 대한 질문이 있습니다.
#include using namespace std; int board[10001][10001]; int n, m, s, e; int can(int w) { queue Q; vector ch(10001, 0); ch[s] = 1; Q.push(s); while(!Q.empty()) { int v = Q.front(); Q.pop(); for(int i = 1; i { if(board[v][i] >= w && ch[i] == 0) { //cout ch[i] = 1; Q.push(i); } } } return ch[e]; } int main() { ios_base::sync_with_stdio(false); freopen("input.txt", "rt", stdin); int lt = 1, rt = 1000000000, mid, res; cin >> n >> m; for(int i = 1; i { int a, b, c; cin >> a >> b >> c; board[a][b] = c; board[b][a] = c; } cin >> s >> e; while(lt { mid = (lt + rt) / 2; if(can(mid)) { //cout res = mid; lt = mid + 1; } else { //cout rt = mid - 1; } } cout return 0; }