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

Автор PHANTOM_23, история, 11 месяцев назад, По-английски

Problem

Submission

Checker comment "wrong answer Test 226: Expected -1, got a Tree !! (test case 226)" I have checked the -1 condition in the beginning

if(m<n || m>n*(n+1ll)/2ll)
    {
        cout<<"-1\n";
        return;
    }
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Hey man your code trips up on the one node cas when n=1 you still fall into the make edges logic and end up printing a false edge like 1 1 so the judge thinkse you handed it a tree instead of just a single node

to fix this slam in an early check if n == 1 then if m == 1 print 1 and return else print -1 and return and only run your normal tree building code when n > 1.