Queries on Graph Problem (Problem D Div1 — Round 233).

Revision en1, by math-is-stupid, 2016-10-07 23:44:52

I am trying to solve Problem D Div1 — 233 http://codeforces.net/contest/398/problem/D. I am getting TLE on testcase 63. Here is my submission http://codeforces.net/contest/398/submission/21266586. According to me, the time complexity of my code is O[q * (S + K)] where q is number of queries and S (S ~ 500) is constant size defined for a node to be heavy and K denotes total number of heavy nodes. A node is heavy if degree[node] > S. Please correct me if I am wrong. Can I do something better? What changes should I make in my code? Any insights would be really helpful.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English math-is-stupid 2016-10-07 23:44:52 646 Initial revision (published)