微软2017年预科生计划在线编程笔试第二场-#1497 : Queen Attack
来源:互联网 发布:数据库设计原则,范式 编辑:程序博客网 时间:2024/05/16 11:32
http://hihocoder.com/problemset/problem/1497
题意理解:看横坐标一样有多少对,当然还有纵坐标,i-j和i+j
急转弯:计算复杂度,因为最后有100000个旗子,并且他们的坐标很大,所以统计的时候要用map
算法:无
数据结构:map,在python中有dict
from __future__ import print_function##'test for map'__author__ = 'hjkruclion'import functoolsimport sysimport ioimport copydef read_int(): """Read a seris of numbers.""" return list(map(int, sys.stdin.readline().split()))n = read_int()[0]a = {}b = {}c = {}d = {}for x in range(n): t = read_int() i = copy.copy(t[0]) j = copy.copy(t[1]) # print(i) a[i] = a.get(i, 0) + 1 b[j] = b.get(j, 0) + 1 c[i + j] = c.get(i + j, 0) + 1 d[i - j] = d.get(i - j, 0) + 1res = 0for (_, x) in a.items(): res += x * (x - 1)for (_, x) in b.items(): res += x * (x - 1)for (_, x) in c.items(): res += x * (x - 1)for (_, x) in d.items(): res += x * (x - 1)print(int(res/2))
阅读全文
0 0
- 微软2017年预科生计划在线编程笔试第二场-#1497 : Queen Attack
- 【微软2017年预科生计划在线编程笔试第二场 A】Queen Attack
- 微软2017年预科生计划在线编程笔试第二场B题Diligent Robots
- 微软2017年预科生计划在线编程笔试第二场-#1498 : Diligent Robots
- 微软2017年预科生计划在线编程笔试第二场-#1499 : A Box of Coins
- 微软2017年预科生计划在线编程笔试第二场-#1500 : EL SUENO
- 微软2017年预科生计划在线编程笔试 题目1 : Legendary Items
- 微软2017年预科生计划在线编程笔试题Legendary Items
- 微软2017年预科生计划在线编程笔试_上
- [hihocoder1489][微软2017年预科生计划在线编程笔试][Legendary Items]
- 微软2017年预科生计划在线编程笔试,附解题思路
- 微软2017年预科生计划在线编程笔试-#1489 : Legendary Items
- 微软2017年预科生计划在线编程笔试-#1490 : Tree Restoration
- 微软2017年预科生计划在线编程笔试-#1491 : Monster Killing
- 微软2017年预科生计划在线编程笔试-#1492 : Parentheses Sequence
- 微软预科生计划skype在线面试题
- 2017微软预科生计划面试(三面全)
- [hihoCoder 1187] Divisors (微软预科生计划-探星夏令营在线测试)
- 【Python】简单学习(一)
- IntelliJ IDEA使用之一—打开Settings
- 美国全力封杀卡巴斯基
- POP3遇到的编码问题
- [Project] Simulate HTTP Post Request to obtain data from Web Page by using Python Scrapy Framework
- 微软2017年预科生计划在线编程笔试第二场-#1497 : Queen Attack
- 正则表达式 分支条件
- VT开启教程
- 【记录】Python小伎俩
- img标签总结
- omnet++ 分配信道的问题
- 策略设计模式
- 《Python核心编程(第2版)》读书笔记(6)之用列表模拟堆栈(关键词:Python/列表/堆栈/stack.py)
- CS231n学习笔记--4.Backpropagation and Neural Networks