artyommaths's blog

By artyommaths, history, 10 years ago, In English

Test works on my local mac but fails when I submit it. I use xcode and C++. What are best practices when coding on mac with xcode in C++ in order to have compatible solutions?

  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
10 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Undefined Behaviour?

Check it out in the Customtest function to see what you get on Codeforces.

Besides, the problem might come from the differences between (Linux, Mac) and (Windows). You know, things like "%lld" and "%I64d".

»
10 years ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

I believe you're talking about your last submission: 14812227. Please include submission ID and link to the problem in the post — we don't read your mind and seeing the actual code makes helping significantly easier.

sort in C++ is not guaranteed to be stable, that is, if two elements are "equal" regarding to comparator, they can be ordered arbitrary in the output. For example, two consecutive calls of 'sort' do not make any sense. Use 'stable_sort' (which is somewhat slower) if you want stable sorting.

I think you wanted to sort pairs lexicographically. You'd better either make a single comparator which does all the job (i.e. checks for first items to be equal and then proceeds) or just do not pass any comparator at all — pairs are sorted lexicogrsphically by default.