Created
December 9, 2014 10:35
-
-
Save lethe2211/9a3f2853d59acd4f0df3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
class Hoge(object): | |
def __init__(self): | |
pass | |
def func(self): | |
''' | |
insert your code | |
''' | |
n, m = map(int, raw_input().split()) | |
info = [] | |
high = [] | |
for i in range(m): | |
a, b = map(int, raw_input().split()) | |
info.append((a, b)) | |
if b == 1: | |
high.append(a) | |
while True: | |
flg = False | |
for a, b in info: | |
# print a, b | |
# print high | |
if b in high and not a in high: | |
high.append(a) | |
# print a | |
flg = True | |
if flg == True: | |
continue | |
else: | |
break | |
# print high | |
print len(high) + 1 | |
return None | |
if __name__ == '__main__': | |
h = Hoge() | |
h.func() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment