Peregrine_Falcon's blog

By Peregrine_Falcon, history, 6 years ago, In English

I was trying to solve this problem. With this code I got several WA & wasted hours of time by debugging it. But I've changed to this got AC! With no change of idea. All I changed was a line of code O_o.

it = lower_bound( v.begin() , v.end() , com [ i ].size() );

to

a = com [ i ].size();

it = lower_bound( v.begin() , v.end() , a );

Is there any problem with that?

Thank You.

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

You also changed: v.erase( v.begin() , v.begin()+(it — v.begin() +1) ); to: *it = -1; sort( v.begin() , v.end() );

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    this is the exact code as the accepted code, I just changed the described change, it's giving WA.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +14 Vote: I do not like it

      look at this

      simply use : it = lower_bound( v.begin() , v.end() , int(com [ i ].size()) ); lower_bound is a template function it detects type(T) by last parameter.

      vector.size returning size_t (Unsigned int) so you have lower_bound for size_t values vs int values.