声明:
叠甲:
leetcodeHard
),因为不是真的找所以就写个名字,发出来主要是为了博看官一笑,希望不要做价值判断,非要做我也不介意但我大概率不会解释的const PRIORITY = [
{1, c => c.code.codeforces.rating >= 2000},
{2, c => leetcodeHard(c)},
{3, c => c.singing.lesMiserables.canSingAllTunes && c.isV2EXer},
{4, c => c.videoGame.theWitness.hasFullAchievements},
{5, c => c.body.hand.isPretty && willingHoldHands(c) && c.isV2EXer}
];
const CONDITIONS = [
c => isStudent(c),
c => c.gender == male,
c => c.major == "math" || "CS" || "EE",
c => knowsLesMiserables(c)
];
const finalJudging = [
c => c.code.codeforces.rating,
c => -c.education.schoolRank,
c => -c.education.majorRank,
c => c.singing.ability
]
Candidate select(candidates) {
vector<vector> priorityCandidates(4);
for (c : candidates) {
int x = 0;
for (p : PRIORITY) {
if (p.second(c)) {
x = p.first;
break;
}
}
if (x == 1) {
return c;
// 不会吧不会吧不会真有 cf2000 吧
}else if (x > 0) {
priorityCandidates[x-2].push_back(c);
}
}
for (candidatesList : priorityCandidates) {
Candidate result;
int prev = 0;
for (c : candidatesList) {
int x = conditionsMetCount(c);
if (x == 4) {
return c;
}
if (x > prev) {
prev = x;
result = c;
}
}
if (result) {
return result;
}
}
vector<Candidate> conditionCandidates;
for (c : candidates) {
bool meetAllConditions = true;
for (con : conditions) {
meetAllConditions &= con(c);
}
if (meetAllConditions) {
conditionCandidates.push_back(c);
}
}
if (conditionCandidates.empty()) {
throw error("没有找到合适的人!");
}
sort(conditionCandidates, (a, b) => {
for (f : finalJudging) {
if (f(a) != f(b)) {
return f(a) > f(b);
}
}
});
return conditionCandidates[0];
}
try {
Candidate chosen = select(candidates);
// 因为 candidates 数组本身就是按时间顺序排序的,所以有几个默认返回前者的情况。
} catch () {
cry();
}
注:
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.