ハッカーカップ予選ラウンド解析+ FacebookハッカーカップオンラインラウンドI転送

Facebook Hacker Cup 2011は4ラウンドで開催されます-予選、2回のオンラインラウンド、メインオフィスでの決勝戦。

Habré公式に発表した予選ラウンドは無事に終了しました。
ラウンドの結果は、最初のオンラインツアーに参加した5846人のプレーヤーを示しています。
予選ラウンドの参加者には3つのタスクが提供されました。合格すれば、いずれかを正しく解決することができました。

しかし、完了に近づいて中断された最初のオンラインラウンドは、技術的な問題により少なくとも1週間延期されました。
ラウンド1の残りのサブラウンドは、スムーズに実行できると確信できるまでプッシュバックすることにしました。 更新はここで行われますが、少なくとも次の週末までサブラウンドは発生しないと安全に想定できます。
画像

スペースを節約するために、条件の転送を減らし、ソリューションに必要なエッセンスを残します。 完全な条件は英語で原文で利用可能です。

タスク1.「ダブルスクエア」



整数の2つの完全な2乗の合計として整数の表現の数を見つけます(たとえば、10 = 1 ^ 2 + 3 ^ 2-1つの展開と25 = 5 ^ 2 + 0 ^ 2 = 4 ^ 2 + 3 ^ 2 2つの異なる分解) 。

着信番号へ:
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です。 私たちは、以下への貢献を独自に検討します。

次に、取得した確率を(通常の方法で)追加して、3番目の層を取得します。これが最後です。 (そうでない場合、ゼロ以外の確率を持つ各要素について、同様のプロセスを開始します)。
中央または右の窓からコインを投げるだけで、同じ確率で中央の出口に着くことができます。
このFacebookのソース形式では、問題のフィールドは次の行で表されます:3 4 1 1 0

次に、このアイデアを実装します。
#!/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 .
  1. #!/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 .
  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 .
  3. #!/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 .
  4. #!/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 .
  5. #!/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 .
  6. #!/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 .
  7. #!/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 .
  8. #!/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 .
  9. #!/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 .
  10. #!/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 .
  11. #!/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 .
  12. #!/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 .
  13. #!/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 .
  14. #!/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 .
  15. #!/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 .
  16. #!/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 .
  17. #!/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 .
  18. #!/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 .
  19. #!/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 .
  20. #!/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 .
  21. #!/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 .
  22. #!/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 .
  23. #!/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 .
  24. #!/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 .
  25. #!/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 .
  26. #!/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 .
  27. #!/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 .
  28. #!/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 .
  29. #!/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 .
  30. #!/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 .
  31. #!/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 .
  32. #!/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 .
  33. #!/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 .
  34. #!/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 .
  35. #!/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 .
  36. #!/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 .
  37. #!/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 .
  38. #!/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 .
  39. #!/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 .
  40. #!/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 .
  41. #!/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 .
  42. #!/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 .
  43. #!/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 .
  44. #!/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 .
  45. #!/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 .
  46. #!/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 .
  47. #!/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 .
  48. #!/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 .
  49. #!/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 .
  50. #!/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 .
  51. #!/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 .
  52. #!/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 .
  53. #!/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 .
  54. #!/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 .
  55. #!/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 .
  56. #!/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 .
  57. #!/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 .
  58. #!/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 .
  59. #!/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 .
  60. #!/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 .
  61. #!/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 .
  62. #!/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 .
  63. #!/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 .
  64. #!/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 .
  65. #!/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 .
  66. #!/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 .
  67. #!/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 .
  68. #!/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 .
  69. #!/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 .
  70. #!/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 .
  71. #!/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 .
  72. #!/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 .
  73. #!/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 .
  74. #!/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 .
  75. #!/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 .
  76. #!/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!)
  1. itertoolsインポート順列から
  2. source = "jibw ji jp bw jibw"
  3. words = source.split()
  4. answer = min( "" .join(組み合わせ)順列(単語)の組み合わせ)
*このソースコードは、 ソースコードハイライターで強調表示されました。

条件N <= 9により、階乗の複雑さは良好です
プラスこれ彼のコメント


Skiminok habrayuzerの複雑さO(N log N)からのソリューション
  1. functools import cmp_to_key から
  2. def comp(a、b):
  3. a + b <b + a else 1の場合 -1を返し a + b> b + a else 0の場合
  4. def solve(s):
  5. return "" .join(ソート済み(s.split()、key = cmp_to_key(comp)))
*このソースコードは、 ソースコードハイライターで強調表示されました。

プラスこれ彼のコメント

funcaの短いラムダバージョン
  1. def solve(s):
  2. return "" .join(ソート済み(s.split()、cmp = lambda a、b:cmp(a + b、b + a)))
*このソースコードは、 ソースコードハイライターで強調表示されました。

さらにこのコメント

Source: https://habr.com/ru/post/J111898/


All Articles