考勤信息
要求:1s 262144k 公司用一个字符串来表示员工的出勤信息: absent 缺勤 late 迟到 leaveearly 早退 present 正常上班
能获得全勤奖的条件: 缺勤次数不超过1次 不能连续迟到/早退 任意的连续7次考勤中,缺勤、迟到、早退的次数不超过3次
eg: 输入: 2 present present present 输出:true true
输入: 2 present leaveearly late present present 输出: true false
import sys
def award(s):
if s.count('absent') > 1:
return 'false'
if s.count('late late') > 0 or s.count('leaveearly leaveearly') > 0 or s.count('late leaveearly') or s.count('leaveearly late'):
return 'false'
sl = s.split(" ")
for i in range(len(sl)):
if sl[i] == 'absent' or sl[i] == 'late' or sl[i] == 'leaveearly':
num = 0
l = sl[i+1:i+7]
num += l.count('absent')
num += l.count('late')
num += l.count('leaveearly')
if num > 2:
return 'false'
return 'true'
n = int(sys.stdin.readline())
res = []
for i in range(n):
line = sys.stdin.readline().strip()
res.append(award(line))
print(" ".join(res))
|