### ROC-AUC值

``````10
1 0.9
0 0.7
1 0.6
0 0.55
1 0.52
0 0.4
1 0.38
0 0.35
1 0.31
0 0.1``````
``````输出：
0.68``````

``````N = int(input())
gt, pre = [], []
for _ in range(N):
temp = list(map(float, input().split()))
gt.append(temp[0])
pre.append(temp[-1])

positive, negitive = [], []
for idx, i in enumerate(gt):
if i == 1.:
positive.append(idx)
else:
negitive.append(idx)

total = len(positive) * len(negitive)
fenzi = 0
for i in positive:
for j in negitive:
if pre[i] > pre[j]:
fenzi += 1.
elif pre[i] == pre[j]:
fenzi += 0.5

output = fenzi / total
print('%.2f' % output)``````

### 车站时刻表分组

``````输入

``````样例输入
aabbcddc

2,2,4``````
``````import sys

def fun(line_one):
ans = []
if len(line_one) == 0:
return []
for i in range(len(line_one)):
if line_one[0] == line_one[i]:
ans.append(i)

length = len(line_one[:ans[-1]])+1
return [length] + fun(line_one[ans[-1]+1:])

if __name__ == "__main__":
n = list(input())

### 字符串编辑距离

1.删除一个字符
2.插入一个字符
3.修改一个字符

``````输入：

``````def strdist(str1, str2):

t = [[0 for x in range(len(str2)+1)] for x in range(len(str1)+1)]
for i in range(len(str1)+1):
for j in range(len(str2)+1):
if i == 0:
t[i][j] = j
elif j == 0:
t[i][j] = i
elif str1[i-1] == str2[j-1]:
t[i][j] = t[i-1][j-1]
else:
t[i][j] = 1 + min(t[i][j-1], t[i-1][j], t[i-1][j-1])
return t[len(str1)][len(str2)]
# str1 = '携程欢迎您'
# str2 = '欢迎你程里人'
str_ = list(map(str, input().split('<ctrip>')))
str1 = str_[0]
str2 = str_[1]
print(strdist(str1, str2))``````

### 螺旋数组

``````输入：
3 3
1 2 3
4 5 6
7 8 9

1，2，3，6，9，8，7，4，5``````

3.给定一个词典W(保证词典的数据不重复),输入一句文本S,使用词典进行分词。如果文本能够根据词典进行分词，则输出YES，否则输出NO

YES

``````import jieba
w = list(input().split(','))
s = input()
# print(w, s)
seq_list=list(jieba.cut(s, cut_all=False))
# print(seq_list)
count = []
for i in seq_list:
# print(i)
if i in w:
count.append(1)
else:
count.append(0)
if 0 in count:
print('NO')
else:
print('YES')``````