Why am I getting wrong answer

My code is clearing the sample test case but not clearing the submission test case
Link:

@shreyanshgupta
Your logic is correct but there are few mistakes in your code.

  1. Check line 64, Number of edges is m not n. Change the condition of loop to i<m
  2. Output should be in different line for each testcase. You have forget to move to next line. Simply write cout<<endl; after line no. 52
  3. Check line no. 17, why i<=4, it should be i<=n
    I have made above changes in your code. Here is the updated code https://ide.codingblocks.com/s/234387
1 Like