직접 해보니
n=0, k=100000
에서는 런타임 에러가 나네요.([with exit code 138])
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
위의 설정으로 컴파일한 결과입니다.
xzvfinet 6년 전
아래 코드는 제가 제출한 코드이고, 통과했습니다.
그런데 백준님이 짠 코드랑 비교해보았을 때 next[i] 인덱스가 음수일 경우를 걸러주는 부분이 빠져있고, 실제로 출력해보아도 음수가
visited[next[i]] = true;
dist[next[i]] = newDist;
q.push(next[i]);
위 세 줄에 대입되는데도 불구하고 통과하더라구요.
C++ 컴파일러의 느슨함 때문에 어쩔 수 없는건지, 테스트 케이스로 보강할 수 있는 부분인 저는 잘 모르겠어서 고수분들께 질문드립니다.