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

相关文章

全面解析HTML5中Checkbox标签

《全面解析HTML5中Checkbox标签》Checkbox是HTML5中非常重要的表单元素之一,通过合理使用其属性和样式自定义方法,可以为用户提供丰富多样的交互体验,这篇文章给大家介绍HTML5中C... 在html5中,Checkbox(复选框)是一种常用的表单元素,允许用户在一组选项中选择多个项目。本

Python包管理工具核心指令uvx举例详细解析

《Python包管理工具核心指令uvx举例详细解析》:本文主要介绍Python包管理工具核心指令uvx的相关资料,uvx是uv工具链中用于临时运行Python命令行工具的高效执行器,依托Rust实... 目录一、uvx 的定位与核心功能二、uvx 的典型应用场景三、uvx 与传统工具对比四、uvx 的技术实

SpringBoot排查和解决JSON解析错误(400 Bad Request)的方法

《SpringBoot排查和解决JSON解析错误(400BadRequest)的方法》在开发SpringBootRESTfulAPI时,客户端与服务端的数据交互通常使用JSON格式,然而,JSON... 目录问题背景1. 问题描述2. 错误分析解决方案1. 手动重新输入jsON2. 使用工具清理JSON3.

Redis过期删除机制与内存淘汰策略的解析指南

《Redis过期删除机制与内存淘汰策略的解析指南》在使用Redis构建缓存系统时,很多开发者只设置了EXPIRE但却忽略了背后Redis的过期删除机制与内存淘汰策略,下面小编就来和大家详细介绍一下... 目录1、简述2、Redis http://www.chinasem.cn的过期删除策略(Key Expir

Go学习记录之runtime包深入解析

《Go学习记录之runtime包深入解析》Go语言runtime包管理运行时环境,涵盖goroutine调度、内存分配、垃圾回收、类型信息等核心功能,:本文主要介绍Go学习记录之runtime包的... 目录前言:一、runtime包内容学习1、作用:① Goroutine和并发控制:② 垃圾回收:③ 栈和

Spring组件实例化扩展点之InstantiationAwareBeanPostProcessor使用场景解析

《Spring组件实例化扩展点之InstantiationAwareBeanPostProcessor使用场景解析》InstantiationAwareBeanPostProcessor是Spring... 目录一、什么是InstantiationAwareBeanPostProcessor?二、核心方法解

深入解析 Java Future 类及代码示例

《深入解析JavaFuture类及代码示例》JavaFuture是java.util.concurrent包中用于表示异步计算结果的核心接口,下面给大家介绍JavaFuture类及实例代码,感兴... 目录一、Future 类概述二、核心工作机制代码示例执行流程2. 状态机模型3. 核心方法解析行为总结:三

springboot项目中使用JOSN解析库的方法

《springboot项目中使用JOSN解析库的方法》JSON,全程是JavaScriptObjectNotation,是一种轻量级的数据交换格式,本文给大家介绍springboot项目中使用JOSN... 目录一、jsON解析简介二、Spring Boot项目中使用JSON解析1、pom.XML文件引入依

Python中文件读取操作漏洞深度解析与防护指南

《Python中文件读取操作漏洞深度解析与防护指南》在Web应用开发中,文件操作是最基础也最危险的功能之一,这篇文章将全面剖析Python环境中常见的文件读取漏洞类型,成因及防护方案,感兴趣的小伙伴可... 目录引言一、静态资源处理中的路径穿越漏洞1.1 典型漏洞场景1.2 os.path.join()的陷

C#代码实现解析WTGPS和BD数据

《C#代码实现解析WTGPS和BD数据》在现代的导航与定位应用中,准确解析GPS和北斗(BD)等卫星定位数据至关重要,本文将使用C#语言实现解析WTGPS和BD数据,需要的可以了解下... 目录一、代码结构概览1. 核心解析方法2. 位置信息解析3. 经纬度转换方法4. 日期和时间戳解析5. 辅助方法二、L