[c++] ios::sync_with_stdio, cin.tie, cout.tie


[c++] ios::sync_with_stdio, cin.tie, cout.tie

백준을 풀다가 시간제한이 발생했는데 해결 방법을 찾다가 아래 코드를 넣어주니까 해결됐었다. tie? sync? 가 뭐길래!! ios::sync_with_stdio(false) cin.tie(nullptr) cout.tie(nullptr) sync_with_stdio(bool) C와 C++ 표준 stream의 동기화 여부를 설정한다. stream이란 프로그램과 입출력을 하는 단말기 사이에 연결된 통로이다. 일반적으로 C와 C++의 stream은 동기화되어 있다. 한 코드 안에서 C와 C++ 스타일을 혼용하더라도 정상적으로 입출력이 가능한 이유이다. 동기화를 해제한다면 C와 C++은 각각 독립적인 버퍼를 가지게 된다. 동기화를 한하기 때문에 연산이 줄어들게 된다. 이게 바로 ios::sync_with_std..


원문링크 : [c++] ios::sync_with_stdio, cin.tie, cout.tie