9.11 360算法笔试编程题
第一题AC 凑了好久的正则 题意表述不清 根本不知道哪些是特殊字符
验证密码复杂性 时间限制: 3000MS 内存限制: 786432KB 题目描述: 验证密码复杂性是网站在用户输入初始密码后需要进行的一步操作。现在,小A的网站需要验证密码 的复杂性,小A对一个足够复杂的密码拥有如下要求: 1.要有数字 2.要有大写字母 3.要有小写字母 4.要有特殊字符 5.长度不得小于8 现在给你密码,请你判断这个密码是否足够复杂 输入描述 输入包含多组数据,对于每组数据,包含一个字符串S。 输出描述 如果密码足够复杂,输出Ok,否则输出Ilrregular password.请注意输出的大小写。
import sys
import re
def complexity(password):
n = len(password)
if n < 8:
return False
dig, upp, lwr, syb = [False] * 4
for c in password:
if c.isdigit():
dig = True
elif c.isupper():
upp = True
elif c.islower():
lwr = True
if re.match("[a-zA-Z0-9]*$", password):
syb = False
else:
syb = True
return dig and upp and lwr and syb
if __name__ == '__main__':
for line in sys.stdin:
if line == '': break
if complexity(line.strip()):
print("Ok")
else:
print("Irregular password") 第二题 一开始python做到72还是77来着就超时了, 换java抄了一遍ac81%, 开始提示答案错误
企业管理 时间限制: 3000MS 内存限制: 786432KB 题目描述: 企业管理是一个难题, 特别是对于上下班打卡系统来说。小A所在的公司的打卡器坏了,所以打卡 机只记录了今天一段连续的时间内所有的打卡记录。小A是企业的老板, 他从来都是第一个上班, 最晚下班的人。今天他恰好忘记了自己的号码。现在,小A只有-张按时间顺序但记录不全的上下 班记录表。他希望使用这一张表,看出自己的工号是几号。请你帮助小A计算自 己的工号,如果有 多组解,从小到大按顺序输出。 请注意,公司管理规定上班下班必须有打卡记录,但是有可能有部分员工今天请假而没有打卡记 录。 输入描述 输入第一行包含两个整数n,m, n是小A所在公司的人数,m是今天打卡机记录下来的打卡 数量。接下来m行,每行两个整数a,b;, a:;表示这一 次打卡操作人的工号, 若b;为1代表上 班打卡,为0代表下班打卡。 输出描述 输出包含一行,代表小A可能的工号。如果有多解,从小到大全部输出。数据保证至少有一 个解。
line = input().strip().split()
n, m = [int(x) for x in line]
prop = [False] * (n+1)
list = []
for i in range(m):
line = input().strip().split()
list.append([int(x) for x in line])
enter = set()
if list[0][1] == 1:
for i in range(1,m):
if list[i][1] == 0:
if list[i][0] in enter:
pass
else:
prop[list[0][0]] = True
else:
enter.add(list[i][0])
exitt = set()
if list[m-1][1] == 0:
for i in range(m-2,-1,-1):
if list[i][1] == 1:
if list[i][0] in exitt:
pass
else:
prop[list[-1][0]] = True
else:
exitt.add(list[i][0])
enterL = [enum[0] for enum in list if enum[1] == 1]
for k in enterL[1:]:
prop[k] = True
exitL = [enum[0] for enum in list if enum[1] == 0]
exitL.pop()
for k in exitL:
prop[k] = True
res = [str(i) for i in range(1,n+1) if not prop[i]]
print(" ".join(res)) import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[][] list = new int[m][2];
for (int i = 0; i < m; i++) {
list[i][0] = sc.nextInt();
list[i][1] = sc.nextInt();
}
boolean[] prop = new boolean[n+1];
if (list[0][1] == 1) {
HashSet<Integer> enter = new HashSet<>();
for (int i = 1; i < m; i++) {
if (list[i][1] == 0) {
if (!enter.contains(list[i][0])) {
prop[list[0][0]] = true;
break;
}
} else {
enter.add(list[i][0]);
}
}
}
if (list[m-1][1] == 0) {
HashSet<Integer> exitt = new HashSet<>();
for (int i = m-2; i > -1 ; i--) {
if (list[i][1] == 1) {
if (!exitt.contains(list[i][0])) {
prop[list[m-1][0]] = true;
break;
}
} else {
exitt.add(list[i][0]);
}
}
}
List<Integer> enterL = new ArrayList<>();
List<Integer> exitL = new ArrayList<>();
for (int[] enu : list) {
if (enu[1] == 1) enterL.add(enu[0]);
else exitL.add(enu[0]);
}
for (int k : enterL.subList(1, enterL.size())) {
prop[k] = true;
}
for (int k : exitL.subList(0, exitL.size()-1)) {
prop[k] = true;
}
StringBuilder sb = new StringBuilder();
for (int i = 1; i < n+1; i++) {
if (!prop[i]) {
sb.append(i);
sb.append(" ");
}
}
String s = sb.toString();
System.out.println(s.substring(0,s.length()-1));
}
} 这段代码连给的第二个用例都没过
#笔试题目##360公司#5 2
1 1
1 0
应该输出1 2 3 4 5
实际输出2 3 4 5
安克创新 Anker公司福利 823人发布