This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/2_General/IO_Speed.mdx

19 lines
731 B
Text
Raw Normal View History

2020-06-29 01:31:37 +00:00
---
id: io-speed
title: Input / Output Speed
author: ?
description: ""
---
(actually figure out what makes a dif on USACO lol)
## C++
(using scanf, printf instead?)
(not using endl?)
Including `ios_base::sync_with_stdio(0); cin.tie(0);` in the main function can speed up input & output significantly on some tasks. See [here](https://codeforces.com/blog/entry/5217) and [StackOverflow](https://stackoverflow.com/questions/31162367/significance-of-ios-basesync-with-stdiofalse-cin-tienull) for more information.
- Actually, the former link says that it is supposedly prohibited to use `freopen` to redirect `cin` and `cout` if `ios_base::sync_with_stdio(0); cin.tie(0);` is included, but it works properly as far as I know.