BOP 2016复赛题目解析

2024-02-06 12:59
文章标签 题目 解析 2016 复赛 bop

本文主要是介绍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,但是排名靠前的队伍基本都用上了,所以还是不够细心啊……心塞

NameDescriptionTypeOperations
IdEntity IDInt64Equals
CCCitation countInt32none
AA.AuIdAuthor IDInt64Equals
AA.AfIdAuthor affiliation IDInt64Equals
F.FIdField of study IDInt64Equals
J.IdJournal IDInt64Equals
C.IdConference series IDInt64Equals
RIdReference IDInt64Equals

从上面规则描述中的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 编程之美复赛心得,后面若是还有空的话,我会按照他们的语言种类做个整合对比。


这篇关于BOP 2016复赛题目解析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/684394

相关文章

C语言中自动与强制转换全解析

《C语言中自动与强制转换全解析》在编写C程序时,类型转换是确保数据正确性和一致性的关键环节,无论是隐式转换还是显式转换,都各有特点和应用场景,本文将详细探讨C语言中的类型转换机制,帮助您更好地理解并在... 目录类型转换的重要性自动类型转换(隐式转换)强制类型转换(显式转换)常见错误与注意事项总结与建议类型

MySQL 缓存机制与架构解析(最新推荐)

《MySQL缓存机制与架构解析(最新推荐)》本文详细介绍了MySQL的缓存机制和整体架构,包括一级缓存(InnoDBBufferPool)和二级缓存(QueryCache),文章还探讨了SQL... 目录一、mysql缓存机制概述二、MySQL整体架构三、SQL查询执行全流程四、MySQL 8.0为何移除查

在Rust中要用Struct和Enum组织数据的原因解析

《在Rust中要用Struct和Enum组织数据的原因解析》在Rust中,Struct和Enum是组织数据的核心工具,Struct用于将相关字段封装为单一实体,便于管理和扩展,Enum用于明确定义所有... 目录为什么在Rust中要用Struct和Enum组织数据?一、使用struct组织数据:将相关字段绑

使用Java实现一个解析CURL脚本小工具

《使用Java实现一个解析CURL脚本小工具》文章介绍了如何使用Java实现一个解析CURL脚本的工具,该工具可以将CURL脚本中的Header解析为KVMap结构,获取URL路径、请求类型,解析UR... 目录使用示例实现原理具体实现CurlParserUtilCurlEntityICurlHandler

深入解析Spring TransactionTemplate 高级用法(示例代码)

《深入解析SpringTransactionTemplate高级用法(示例代码)》TransactionTemplate是Spring框架中一个强大的工具,它允许开发者以编程方式控制事务,通过... 目录1. TransactionTemplate 的核心概念2. 核心接口和类3. TransactionT

数据库使用之union、union all、各种join的用法区别解析

《数据库使用之union、unionall、各种join的用法区别解析》:本文主要介绍SQL中的Union和UnionAll的区别,包括去重与否以及使用时的注意事项,还详细解释了Join关键字,... 目录一、Union 和Union All1、区别:2、注意点:3、具体举例二、Join关键字的区别&php

Spring IOC控制反转的实现解析

《SpringIOC控制反转的实现解析》:本文主要介绍SpringIOC控制反转的实现,IOC是Spring的核心思想之一,它通过将对象的创建、依赖注入和生命周期管理交给容器来实现解耦,使开发者... 目录1. IOC的基本概念1.1 什么是IOC1.2 IOC与DI的关系2. IOC的设计目标3. IOC

java中的HashSet与 == 和 equals的区别示例解析

《java中的HashSet与==和equals的区别示例解析》HashSet是Java中基于哈希表实现的集合类,特点包括:元素唯一、无序和可包含null,本文给大家介绍java中的HashSe... 目录什么是HashSetHashSet 的主要特点是HashSet 的常用方法hasSet存储为啥是无序的

Linux中shell解析脚本的通配符、元字符、转义符说明

《Linux中shell解析脚本的通配符、元字符、转义符说明》:本文主要介绍shell通配符、元字符、转义符以及shell解析脚本的过程,通配符用于路径扩展,元字符用于多命令分割,转义符用于将特殊... 目录一、linux shell通配符(wildcard)二、shell元字符(特殊字符 Meta)三、s

使用Python实现批量访问URL并解析XML响应功能

《使用Python实现批量访问URL并解析XML响应功能》在现代Web开发和数据抓取中,批量访问URL并解析响应内容是一个常见的需求,本文将详细介绍如何使用Python实现批量访问URL并解析XML响... 目录引言1. 背景与需求2. 工具方法实现2.1 单URL访问与解析代码实现代码说明2.2 示例调用