Habréが公式に発表した予選ラウンドは無事に終了しました。
ラウンドの結果は、最初のオンラインツアーに参加した5846人のプレーヤーを示しています。
予選ラウンドの参加者には3つのタスクが提供されました。合格すれば、いずれかを正しく解決することができました。
しかし、完了に近づいて中断された最初のオンラインラウンドは、技術的な問題により少なくとも1週間延期されました。
ラウンド1の残りのサブラウンドは、スムーズに実行できると確信できるまでプッシュバックすることにしました。 更新はここで行われますが、少なくとも次の週末までサブラウンドは発生しないと安全に想定できます。
スペースを節約するために、条件の転送を減らし、ソリューションに必要なエッセンスを残します。 完全な条件は英語で原文で利用可能です。
タスク1.「ダブルスクエア」
整数の2つの完全な2乗の合計として整数の表現の数を見つけます(たとえば、10 = 1 ^ 2 + 3 ^ 2-1つの展開と25 = 5 ^ 2 + 0 ^ 2 = 4 ^ 2 + 3 ^ 2 2つの異なる分解) 。
- ゼロから2147483647までの入力番号の範囲
着信番号へ:
10 25 3 0 1
正解は次のとおりです。
1 2 0 1 1
タスクには時間制限があります-タスクファイルがダウンロードされてから6分が経過する前に回答を送信する必要があります。この場合、分解の数をカウントする必要がある最大100の数字があります。
以下を決定します。
スコア:2147483647のルートは46340.95です。それほど多くありません。
アイデア:0〜46341の完全な正方形で配列を埋めます
その後、タスクはアレイの両端から内側に向かって実行されるようになります。
- 正方形の合計が指定された数より大きい-右の境界線を左にシフトする
- 正方形の合計が指定された数よりも小さい-左の境界線を右に移動します
- 平方の合計は指定された数に等しい-結果をインクリメントする
- 境界線が接続されています-答えを印刷して、次の番号を取得します
それまでの間、手は直接列挙(左から右へ配列をバイパスし、元の数と正方形の差からルートを取得)によって曲がった解決策を手に入れることができます。
コードは提供しません-より興味深いタスクに注意を向けます。
タスク2.ペグゲーム
ワッシャー(赤)は、2つの壁の間に市松模様で固定されています。
コインは緑の円から落下し、パックの上を飛んで左右に均等に跳ね返ります(極端なパックからは常にコインが内側に跳ね返ります)。 落ちるコインは青い円に落ちます-出口。 コインが中央の円に投げられた場合、任意の矢印に沿って移動できます。
入力は「フィールド」のサイズを示します-常に奇数の行、任意の数の列、およびコインを取得する必要がある出口番号。
答えは、ウィンドウ番号と、コインが最高の確率で特定の出力に到達する確率です。
さらに、一部のワッシャーが取り外されます(時々失われます)。
1つのパックが失われた小さなフィールドを検討し、中央の出口に入る必要があります。
解決策
あらゆる種類の方法の計算による再帰は間に合いません。フィールドの最大サイズは99〜100であり、割り当てられた6分間で、最大100個の異なるフィールドを計算し、結果を送り返す時間があります。
重要なアイデア:
下から上へ、出口点から-確率1を入れます。左から上、右から上という2つの点から入ることができます。 これらのポイントから、1/2の確率で出口ポイントに到達します。 確率の加算のルールは、それらの乗算について述べています。 レベルは終了しました。次のページに進んでください:2つのポイントがあり、確率は1/2です。 私たちは、以下への貢献を独自に検討します。
- 私たちは、右に落ちて(パックが上にある)だけで左のポイントに着くことができます。 右の「親」から1/2で入ります。 再び、確率を合計します。 1/2 * 1/2を掛けると、0.25になります
- 右の点では、左の親から来る確率は1/2で、右の親から来る確率は1です。 コインは競技場を越えない-壁がある
次に、取得した確率を(通常の方法で)追加して、3番目の層を取得します。これが最後です。 (そうでない場合、ゼロ以外の確率を持つ各要素について、同様のプロセスを開始します)。
中央または右の窓からコインを投げるだけで、同じ確率で中央の出口に着くことができます。
このFacebookのソース形式では、問題のフィールドは次の行で表されます:3 4 1 1 0
- 最初の2桁-フィールドサイズ
- 出口番号(ゼロからカウント)
- 失われたワッシャーの数、次の座標のペアの同じ数(1 0は2行目から削除された最初のワッシャーを意味します)
次に、このアイデアを実装します。
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
#!/usr/bin/python #coding=utf-8 # "" def next(y,x,v): l=[] if (x+y)%2==0: # l.append((y-1,x,v)) return l # if (y-1,x) in skip:# l.append((y-1,x,v)) # - # if x!=0:# if x!=0 and x!=size: if (y,x-1) not in skip:# if x==1 or (y%2==1 and ( x==2 or x==size)): # - , l.append((y-1,x-1,v))# else : l.append((y-1,x-1,v/2.))# - # - # if x!=size:# if (y,x+1) not in skip:# if x==size-1 or (y%2==1 and ( x+1==2 or x+1==size-2)): l.append((y-1,x+1,v))# else : l.append((y-1,x+1,v/2.))# - return l # def rc_to_yx(rs,cs): if rs%2==0: return (rs,cs*2) return (rs,cs*2+1) f = open( 'in' , 'r' ) f.readline() lines_in=f.readlines() for inputWords in lines_in: skip_l = [] skip= set (skip_l) inputWords = inputWords[0:-1].split( ' ' ) inputWords= filter (lambda a: a != "" , inputWords) r= int (inputWords.pop(0)) c= int (inputWords.pop(0)) target= int (inputWords.pop(0)) s_count=inputWords.pop(0) for q in range( int (s_count)): rs=inputWords.pop(0) cs=inputWords.pop(0) skip.add(rc_to_yx( int (rs), int (cs))) # , size=c+c-2 # "" , n={} n[(r-1,target*2+1)]=1 for q in range(r-1): s=n n={} for (b,a),v in s.iteritems(): for (y,x,v) in next(b,a,v): try : n[(y,x)]+=v except KeyError: n[(y,x)]=v #print n # # , maxv=0 maxx=0 for (y,x),v in n.iteritems(): if v>maxv: maxv=v maxx=x #, - 6 print '%(i)d %(d)f' % \ { "i" :(maxx-1)/2, "d" :maxv} print * This source code was highlighted with Source Code Highlighter .
タスク3.「研究生」
このセットの単語を並べ替えて、辞書のように辞書編集順序が最も低い単語を構成します。
たとえば、セットから:熱心な学生のためのfacebookハッカーカップ
単語を取得する必要があります:cupfacebookforhackerstudentsstudious
解決策
habrauzer funcaからのソリューション、複雑さO(N!)
*このソースコードは、 ソースコードハイライターで強調表示されました。
- itertoolsインポート順列から
- source = "jibw ji jp bw jibw"
- words = source.split()
- answer = min( "" .join(組み合わせ)順列(単語)の組み合わせ)
条件N <= 9により、階乗の複雑さは良好です
プラスこれ彼のコメント
Skiminok habrayuzerの複雑さO(N log N)からのソリューション
*このソースコードは、 ソースコードハイライターで強調表示されました。
- functools import cmp_to_key から
- def comp(a、b):
- a + b <b + a else 1の場合 -1を返し 、 a + b> b + a else 0の場合
- def solve(s):
- return "" .join(ソート済み(s.split()、key = cmp_to_key(comp)))
プラスこれ彼のコメント
funcaの短いラムダバージョン
*このソースコードは、 ソースコードハイライターで強調表示されました。
- def solve(s):
- return "" .join(ソート済み(s.split()、cmp = lambda a、b:cmp(a + b、b + a)))
さらにこのコメント