Wrong answer submission and Accepted submission
You can compare them, the only difference is that the Wrong answer submission has an extra
I didn't use
Can someone tell me if there is something wrong with my usage or a compiler bug.
In other words,
cin.tiedoes not return
->sync_with_stdio(0)to operate on. Instead, it returns the C stdin. You can confirm this by running the program
For me, it output
EDIT: This was not the error, see below.
sync_with_stdiois a static function of class
cin.tie(0)->sync_with_stdio(0)is equivalent to
I see, so that wasn't the issue.
I've played around with your code a bit. Haven't found a solution yet, but there might be some ordering issue with the commas. See this submission where I just changed a comma and got it to error at the 94684 number instead of the 47312 number. This might be a situation where C++'s optimizer might be screwing things by re-ordering things around.
94684 is about twice 47312, I think the reason for this is that you changed inSZ from
1 << 17to
1 << 18, so I still think it's
cin.tie(0)->sync_with_stdio(0)that's causing the
OK, I found your error. Using
freadis undefined behavior, and you used
See this submission. the only change is that I used
newto allocate your code so the constructor happens AFTER the
One way of fixing this is by making dummy methods in your IO struct, and defining cin and cout as macros to your IO struct. For example, my IO struct in this submission uses the same idea and functions as a drop-in replacement for my template that has
cin.tie(nullptr)->sync_with_stdio(false)for all practical purposes (other than interactive problems, of course).