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

相关文章

使用Jackson进行JSON生成与解析的新手指南

《使用Jackson进行JSON生成与解析的新手指南》这篇文章主要为大家详细介绍了如何使用Jackson进行JSON生成与解析处理,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1. 核心依赖2. 基础用法2.1 对象转 jsON(序列化)2.2 JSON 转对象(反序列化)3.

Springboot @Autowired和@Resource的区别解析

《Springboot@Autowired和@Resource的区别解析》@Resource是JDK提供的注解,只是Spring在实现上提供了这个注解的功能支持,本文给大家介绍Springboot@... 目录【一】定义【1】@Autowired【2】@Resource【二】区别【1】包含的属性不同【2】@

SpringCloud动态配置注解@RefreshScope与@Component的深度解析

《SpringCloud动态配置注解@RefreshScope与@Component的深度解析》在现代微服务架构中,动态配置管理是一个关键需求,本文将为大家介绍SpringCloud中相关的注解@Re... 目录引言1. @RefreshScope 的作用与原理1.1 什么是 @RefreshScope1.

Java并发编程必备之Synchronized关键字深入解析

《Java并发编程必备之Synchronized关键字深入解析》本文我们深入探索了Java中的Synchronized关键字,包括其互斥性和可重入性的特性,文章详细介绍了Synchronized的三种... 目录一、前言二、Synchronized关键字2.1 Synchronized的特性1. 互斥2.

Java的IO模型、Netty原理解析

《Java的IO模型、Netty原理解析》Java的I/O是以流的方式进行数据输入输出的,Java的类库涉及很多领域的IO内容:标准的输入输出,文件的操作、网络上的数据传输流、字符串流、对象流等,这篇... 目录1.什么是IO2.同步与异步、阻塞与非阻塞3.三种IO模型BIO(blocking I/O)NI

Python 中的异步与同步深度解析(实践记录)

《Python中的异步与同步深度解析(实践记录)》在Python编程世界里,异步和同步的概念是理解程序执行流程和性能优化的关键,这篇文章将带你深入了解它们的差异,以及阻塞和非阻塞的特性,同时通过实际... 目录python中的异步与同步:深度解析与实践异步与同步的定义异步同步阻塞与非阻塞的概念阻塞非阻塞同步

Redis中高并发读写性能的深度解析与优化

《Redis中高并发读写性能的深度解析与优化》Redis作为一款高性能的内存数据库,广泛应用于缓存、消息队列、实时统计等场景,本文将深入探讨Redis的读写并发能力,感兴趣的小伙伴可以了解下... 目录引言一、Redis 并发能力概述1.1 Redis 的读写性能1.2 影响 Redis 并发能力的因素二、

Spring MVC使用视图解析的问题解读

《SpringMVC使用视图解析的问题解读》:本文主要介绍SpringMVC使用视图解析的问题解读,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Spring MVC使用视图解析1. 会使用视图解析的情况2. 不会使用视图解析的情况总结Spring MVC使用视图

利用Python和C++解析gltf文件的示例详解

《利用Python和C++解析gltf文件的示例详解》gltf,全称是GLTransmissionFormat,是一种开放的3D文件格式,Python和C++是两个非常强大的工具,下面我们就来看看如何... 目录什么是gltf文件选择语言的原因安装必要的库解析gltf文件的步骤1. 读取gltf文件2. 提

Java中的runnable 和 callable 区别解析

《Java中的runnable和callable区别解析》Runnable接口用于定义不需要返回结果的任务,而Callable接口可以返回结果并抛出异常,通常与Future结合使用,Runnab... 目录1. Runnable接口1.1 Runnable的定义1.2 Runnable的特点1.3 使用Ru