Critcal structues GYM question

Revision en9, by L_lawliet27, 2020-12-20 09:30:09

Me and my teammate maverick16 were doing the Problem I.Critical Structures, in this Problem set and this is the CF Problem page.

Our approach to this problem is :

find all the bridges and cut vertices first, remove all the bridges. now apply dfs through individual component and count the edges in that component, we divided this into two cases from here:-

  1. there a single cut vertex in the component remove it and count both components (components separated by cut vertex) as different
  2. else take the complete component as a single critical component

p will be number of components counted with this dfs + bridges q will be max edges in a component

But, this approach should fail, when the graph looks like this, however it passed all tests, can anyone help with this?

Our implementation

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en19 English L_lawliet27 2020-12-20 14:45:19 1 (published)
en18 English L_lawliet27 2020-12-20 14:12:13 880 Tiny change: '6.png)\n\n' -> '6.png)\n\n<spoiler summary="try">\ngandu</spoiler>'
en17 English L_lawliet27 2020-12-20 13:22:02 6316 Reverted to en15
en16 English L_lawliet27 2020-12-20 13:21:27 6316 Tiny change: '6.png)\n\n' -> '6.png)\n\n<spoiler summary="Expected Output">\n...\n</spoiler>\n'
en15 English L_lawliet27 2020-12-20 13:07:24 871 Reverted to en12
en14 English L_lawliet27 2020-12-20 13:06:26 6
en13 English L_lawliet27 2020-12-20 13:05:30 865 (saved to drafts)
en12 English L_lawliet27 2020-12-20 10:19:07 0 (published)
en11 English L_lawliet27 2020-12-20 09:55:32 17 Tiny change: ' bridges\nq will b' -> ' bridges\n\nq will b'
en10 English L_lawliet27 2020-12-20 09:52:54 115
en9 English L_lawliet27 2020-12-20 09:30:09 121 Tiny change: 'this algo must fail according to us, when the' -> 'this algo should fail, when the'
en8 English L_lawliet27 2020-12-20 09:23:36 3765
en7 English L_lawliet27 2020-12-20 09:16:50 36
en6 English L_lawliet27 2020-12-20 09:16:11 3754 Tiny change: 'n">\n...\n</spoiler>\nsadfsdf\n' -> 'n">\n...\n...\n</spoiler>\n'
en5 English L_lawliet27 2020-12-19 21:35:16 22
en4 English L_lawliet27 2020-12-19 21:33:20 10 Tiny change: 'n">\n...\n\n~~~~~\n#' -> 'n">\n...\n~~~~~\n#'
en3 English L_lawliet27 2020-12-19 21:27:57 22
en2 English L_lawliet27 2020-12-19 21:05:13 12
en1 English L_lawliet27 2020-12-19 20:51:52 4835 Initial revision (saved to drafts)