BOP 2016复赛题目解析

复赛题
Microsoft Academic Graph (MAG) is a large heterogeneous graph containing entities such as authors, papers, journals, conferences and relations between them. Microsoft provides Academic Knowledge API for this contest. The Entity attributes are defined here.

Participants are supposed to provide a REST service endpoint that can find all the 1-hop, 2-hop, and 3-hop graph paths connecting a given pair of entity identifiers in MAG. The given pair of entity identifiers could be [Id, Id], [Id, AA.AuId], [AA.AuId, Id], [AA.AuId, AA.AuId]. Each node of a path should be one of the following identifiers: Id, F.Fid, J.JId, C.CId, AA.AuId, AA.AfId. Possible edges (a pair of adjacent nodes) of a path are:
规则描述

For each test case, the REST service endpoint will receive a JSON array via HTTP with a pair of entity identifiers, where the identifiers are 64-bit integers, e.g. [123, 456]. The service endpoint needs to respond with a JSON array within 300 seconds. The response JSON array consists of a list of graph paths in the form of [path1, path2, …, pathn], where each path is an array of entity identifiers. For example, if your program finds one 1-hop paths, two 2-hop paths, and one 3-hop paths, the results may look like this: [[123,456], [123,2,456], [123,3,456], [123,4,5,456]]. For a path such as [123,4,5,456], the integers are the identifiers of the entities on the path. After receiving the response, the evaluator will wait for a random period of time before sending the next requests.

Evaluation Metric
The REST service must be deployed to a Standard_A3 virtual machine for the final test. There are no constraints on the programming language you can use.

The test cases are not available before the final evaluation. When the evaluation starts, the evaluator system sends test cases to the REST endpoint of each team individually. Each team will receive 10 test cases (Q1to Q10). The response time for test case Qi is recorded as Ti(1≤i≤10). The final score is calculated using:
评分细则
where Ni is the size of the solution (the total number of correct paths) for Qi , Ki is the total number of paths returned by the REST service, Mi is the number of distinct correct paths returned by the REST service.

思路

题意解析:
为了帮助理解,我把文章实体各个属性含义列在下面,这里只说明比赛中要用到的带id的属性。
其中CC属性让我怨念颇深……比赛的时候完全没注意到,傻傻的用了RId.length,但是排名靠前的队伍基本都用上了,所以还是不够细心啊……心塞

Name Description Type Operations
Id Entity ID Int64 Equals
CC Citation count Int32 none
AA.AuId Author ID Int64 Equals
AA.AfId Author affiliation ID Int64 Equals
F.FId Field of study ID Int64 Equals
J.Id Journal ID Int64 Equals
C.Id Conference series ID Int64 Equals
RId Reference ID Int64 Equals

从上面规则描述中的hop的定义可以看出,路径的组成只有11种:Id-Id, Id-FId, FId-Id, Id-JId, JId-Id, Id-CId, CId-Id,AuId-AFId, AFId-AuId, AuId-Id, Id-AuId。那么针对不同的Id对儿,可以找出下面的规律。

  1. Id-Id, 共计15种

    • 1跳,1种 直达
    • 2跳,5种 Id1-Id-Id2,这种情况单独处理,用RId=Id2的反向查询更快捷。
      Id1-AuId-Id2, Id1-FId-Id2, Id1-JId-Id2, Id1-CId-Id2,
    • 3跳,9种 Id1-Id-Id-Id2,这种情况比较麻烦,需要前向和反向查询,url编写复杂度较高
      Id1-AuId-Id-Id2, Id1-FId-Id-Id2, Id1-JId-Id-Id2, Id1-CId-Id-Id2,Id1-Id-AuId-Id2, Id1-Id-FId-Id2,Id1-Id-JId-Id2,Id1-Id-CId-Id2
  2. Id-AuId,共计8种

    • 1跳,1种 直达
    • 2跳,1种 Id-Id-AuId,1次查询就好
    • 3跳,6种 Id-Id-Id-AuId, Id-AuId-AfId-AuId,Id-AuId-Id-AuId,Id-FId-Id-AuId,Id-JId-Id-AuId,Id-CId-Id-AuId
  3. AuId-Id,共计8种

    • 1跳,1种 直达
    • 2跳,1种 AuId-Id-Id
    • 3跳,6种 AuId-Id-Id-Id, AuId-AfId-AuId-Id, AuId-Id-JId-Id, AuId-Id-CId-Id, AuId-Id-FId-Id,AuId-Id-AuId-Id
  4. AuId-AuId 共计3种

    • 1跳,木有
    • 2跳,2种 AuId-Id-AuId, AuId-AfId-AuId,
    • 3跳,1种 AuId-Id-Id-AuId

    看起来这是比较复杂的,需要分别写出34种的情况,但是这些可能性中有不少可以复用的。比如,通过查询一次id1,id2的属性值,就可以写出Id1-AuId-Id2, Id1-FId-Id2, Id1-JId-Id2, Id1-CId-Id2这四种2hop的了。

其实,准确无误的完成上面的思路,才刚刚进入可以比拼的大队。如果思路够清楚,花费1-2天的专注编程就可以了。
剩下的大部分时间还是花在了各种各样减少时间消耗的trick上,然而这部分我做的并不好,太过于依赖缓存的Map,导致最后的失败。

对于这些各种各样的trick感兴趣的可以看我上一篇博客:2016 BOP 编程之美复赛心得,后面若是还有空的话,我会按照他们的语言种类做个整合对比。


全部评论

相关推荐

03-12 14:52
已编辑
长沙学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
# 春招至今,你的战绩如何? #
13285次浏览 128人参与
# AI面会问哪些问题? #
779次浏览 18人参与
# MiniMax求职进展汇总 #
24553次浏览 313人参与
# 你的实习产出是真实的还是包装的? #
2363次浏览 47人参与
# AI时代,哪个岗位还有“活路” #
2443次浏览 47人参与
# 长得好看会提高面试通过率吗? #
2105次浏览 39人参与
# 巨人网络春招 #
11453次浏览 224人参与
# 你做过最难的笔试是哪家公司 #
980次浏览 18人参与
# HR最不可信的一句话是__ #
874次浏览 31人参与
# 沪漂/北漂你觉得哪个更苦? #
859次浏览 28人参与
# 军工所铁饭碗 vs 互联网高薪资,你会选谁 #
7883次浏览 43人参与
# XX请雇我工作 #
51096次浏览 171人参与
# 简历中的项目经历要怎么写? #
310725次浏览 4245人参与
# 简历第一个项目做什么 #
31944次浏览 353人参与
# 不考虑薪资和职业,你最想做什么工作呢? #
152716次浏览 888人参与
# 当下环境,你会继续卷互联网,还是看其他行业机会 #
187473次浏览 1123人参与
# AI时代,哪些岗位最容易被淘汰 #
64356次浏览 855人参与
# 如果重来一次你还会读研吗 #
229933次浏览 2011人参与
# 正在春招的你,也参与了去年秋招吗? #
364010次浏览 2640人参与
# 腾讯音乐求职进展汇总 #
160790次浏览 1114人参与
# 你怎么看待AI面试 #
180504次浏览 1286人参与
# 投格力的你,拿到offer了吗? #
178015次浏览 889人参与
牛客网
牛客网在线编程
牛客网题解
牛客企业服务