checkMate09's blog

By checkMate09, history, 8 years ago, In English

i was coding solution for the problem C. The Smallest String Concatenation . the solution depends mainly on overriding the cmp() function. first version caused RTE

bool cmp(const string &a, const string &b){

    return a+b <= b+a;
}

second version Accepted without = sign.

bool cmp(const string &a, const string &b){

    return a+b < b+a;
}

why the = sign caused RTE ?

UPD : RTE submission http://codeforces.com/contest/632/submission/20033016

  • Vote: I like it
  • +12
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can you provide a link to your submissions please.

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Cycle.

»
8 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Comparators in C++ are different than Java. In C++ you should always return strictly bigger or smaller. Unlike Java where equality is okay.

I'm not sure about details, but for comparing stuff, always use < or > in C++. ( At least in terms of what is commonly used for CP).

RTE happens because it can't decide which should come first, kind of a cyclic bigger than or equal like a guy pointed above.