4 ms·
"The solution presented here is ~550x faster than the following naive program." ... std::cin >> v; ... Oh come on! That's I/O for every item, I'm surprised
by _a_a_a_ 2y ago
"The solution presented here is ~550x faster than the following naive program."
... std::cin >> v; ...
Oh come on! That's I/O for every item, I'm surprised it's not even slower.
- BoardsOfCanada 2y agoYeah, how does the proposed solution solve the problem as stated: "Print the number of bytes whose value equals 127 in a 250MB stream of bytes uniformly sampled from [0, 255] sent to standard input."
- anonymoushn 2y agoWhen stdin is a file, as it is in this case, you can mmap it.
- Iwan-Zotow 2y agotechnically not an equivalent problem - you can't map a stream
- anonymoushn 2y agoThe whole problem statement isn't equivalent to the substring of the problem statement that GP quoted? I agree. For example, the whole problem statement includes a part that specifies that stdin is a file stored in hugetlbfs.
- gpderetta 2y agoCin is buffered, do it is not technically doing I/O for every time. It is still dog slow of course.
- _a_a_a_ 2y agoOops, buffered of course, you're right.