Блог пользователя artyommaths

Автор artyommaths, история, 10 лет назад, По-английски

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?

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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 лет назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

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.