Edit: Problem fixed. It turns out that I output the answer in a separate function before I input and output the file, which causes the problem. Thanks for everyone that helps :)↵
↵
Edit: I did write output file ↵
↵
↵
↵
I've been doing some past USACO Gold problems lately, but I have met some troubles regarding submission. Although my program outputs the correct answer, it keeps telling me that the answer is incorrect. I've met these kind of troubles before, so I thought its just a format issue. But no matter how I adjust the way I output the answer, it doesn't work. ↵
↵
For example, I have tried ↵
``` cout << ans << "\n"; ```↵
``` cout << ans << endl; ```↵
``` cout << ans << " "; ```↵
``` cout << ans; ```↵
but non of them works. ↵
↵
Here are two screenshots: ↵
↵
↵
↵
↵
Can someone please help me with that? I just don't want to run into these kind of troubles during real contest lol. Thanks!
↵
Edit: I did write output file ↵
↵
↵
↵
I've been doing some past USACO Gold problems lately, but I have met some troubles regarding submission. Although my program outputs the correct answer, it keeps telling me that the answer is incorrect. I've met these kind of troubles before, so I thought its just a format issue. But no matter how I adjust the way I output the answer, it doesn't work. ↵
↵
For example, I have tried ↵
``` cout << ans << "\n"; ```↵
``` cout << ans << endl; ```↵
``` cout << ans << " "; ```↵
``` cout << ans; ```↵
but non of them works. ↵
↵
Here are two screenshots: ↵
↵
↵
↵
↵
Can someone please help me with that? I just don't want to run into these kind of troubles during real contest lol. Thanks!