文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ZOJ Problem Set - 1201 Inversion (Python)

ZOJ Problem Set - 1201 Inversion (Python)

时间:2011-02-17  来源:天下之大

import sys

def readArraySize():
line
= sys.stdin.readline()
a
= line.split()
n
= int(a[0])
return n
def main():
n
= readArraySize()
while (n) != 0:
line
= sys.stdin.readline()
a
= line.split()
m
= a.pop(0)
if m == 'P':
P2I(a, n)
else:
I2P(a, n)
n
= readArraySize()
return 0

def P2I(b, n):
result
= [0] * n
for i in range(n):
for j in range(i):
if b[j] > b[i]:
result[int(b[i])
- 1] = result[int(b[i]) - 1] + 1
print result

def I2P(b, n):
result
= [n + 1] * n
for i in range(n):
j
= 0
while result[j] < i + 1:
j
= j + 1
for k in range(int(b[i])): #find a place for i+1
j = j + 1
while result[j] < i + 1:
j
= j + 1
result[j]
= i + 1
print result

if __name__ == '__main__':
main()

最近对AC有困扰啊。。。测试通过,无法AC,无法找出bug,请高手斧正!

相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载