jan25's blog

By jan25, history, 6 years ago, In English

Hi folks, I keep getting Runtime error with this implementation in Python3.6. Same implementation in C++11 is Accepted Pls comment if you find something off. Thanks! Here's the link to problem

n, m = map(int, input().split())
g = {v : [] for v in range(1, n + 1)}
for e in range(m):
    u, v = map(int, input().split())
    g[u].append(v)
    g[v].append(u)

glob_vis = set()
def bfs(v):
    vis = set([v])
    glob_vis.add(v)
    q = [v]
    qi, e = 0, 0
    while qi < len(q):
        v = q[qi]
        for u in g[v]:
            e += 1
            if u not in vis:
               vis.add(u)
               glob_vis.add(u)
               q.append(u)
        qi += 1
    return [e//2, len(vis)]

min_sep = 0
for v in range(1, n + 1):
    if v not in glob_vis:
        res = bfs(v)
        if res[0] == res[1] - 1:
            min_sep += 1

print (min_sep)

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By jan25, history, 9 years ago, In English

Hi all

Our Submission for Problem F in yesterday's round was Accepted and other submissions were either WA or TLE. But now all the submissions are showing skipped.

Kindly the CF and round admins have a look into it.

Thanks

PS — BEFORE DOWNVOTING READ THROUGH THE COMMENT CHAIN

Full text and comments »

  • Vote: I like it
  • -24
  • Vote: I do not like it

By jan25, 9 years ago, In English

Very good course archive for competitive programming: link

I learned a lot from this course alone. Thanks to Jaehyun Park(Stanford)

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it