Google Code Jam 2015 Round1A 题解
快一年没有做题了, 今天跟了一下 GCJ Round 1A的题目, 感觉难度偏简单了, 很快搞定了第一题, 第二题二分稍微考了一下, 还剩下一个多小时, 没仔细想第三题, 以为 前两个题目差不多可以晋级了. 切出去玩了一会, 大概剩半小时, 发现自己的排名逐渐快超 1k了, 果断决定搞出第三题的小数据. 然后简单的O(n^3)的枚举过了. 然后有惊无险的晋级了.
第一题,读懂题目,然后计算就很好说了. 第二题,计算最小公倍数的那种肯定是行不通的, 二分 t时刻 已经剪完了多少个, 正在剪的有多少个, 然后准备剪的有多少个, 然后二分.
第三题, 其实当时已经想到了解决思路, 去掉点然后没有凸包就意味着极角排序之后, 删掉多少个中间元素, 可以让某两个极角序列的interval 大于 Pi. 复杂度就是 O(n^2lgn) nlgn是极角排序负责度, n是枚举每一个需要处理的点.
1: #include <bits/stdc++.h>
2: using namespace std;
3:
4: int n;
5: double x[3001], y[3001];
6: double pi = atan(1) * 4;
7:
8: int solve(vector <double> lis)
9: {
10: if(n == 1)
11: return 0;
12: lis.push_back(100);
13: int p = 0;
14: int ret = 1000000;
15: for(int i = 0; i < n; i++)
16: {
17: while(lis[p+1] <= lis[i] + pi - 1e-8)
18: p ++;
19: ret = min(ret, p - i);
20: }
21: return ret;
22: }
23:
24: void solve()
25: {
26: cin >> n;
27: cout << endl;
28: for(int i = 1; i <= n; i++)
29: {
30: cin >> x[i] >> y[i];
31: }
32: for(int i = 1; i <= n; i++)
33: {
34: vector <double> dir;
35: for(int j = 1; j <= n; j++)
36: if(i != j)
37: {
38: double v = atan2(y[j] - y[i], x[j] - x[i]);
39: dir.push_back(v);
40: dir.push_back(v + 2 * pi);
41: }
42: sort(dir.begin(), dir.end());
43: cout << solve(dir) << endl;
44: }
45: }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
Google Code Jam 2015 Round1A 题解的更多相关文章
- Google Code Jam 2015 R1C B
题意:给出一个键盘,按键都是大写字母.给出一个目标单词和一个长度L.最大值或者最大长度都是100.现在随机按键盘,每个按键的概率相同. 敲击出一个长度为L的序列.求该序列中目标单词最多可能出现几次,期 ...
- Google Code Jam 2015 R2 C
题意:给出若干个句子,每个句子包含多个单词.确定第一句是英文,第二句是法文.后面的句子两者都有可能.两个语种会有重复单词. 现在要找出一种分配方法(给每个句子指定其文种),使得既是英文也是法文的单词数 ...
- Google Code Jam 2014 Qualification 题解
拿下 ABD, 顺利晋级, 预赛的时候C没有仔细想,推荐C题,一个非常不错的构造题目! A Magic Trick 简单的题目来取得集合的交并 1: #include <iostream> ...
- [C++]Infinite House of Pancakes——Google Code Jam 2015 Qualification Round
Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...
- [C++]Standing Ovation——Google Code Jam 2015 Qualification Round
Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...
- [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha
Problem B. Cookie Clicker Alpha Introduction Cookie Clicker is a Javascript game by Orteil, where ...
- [Google Code Jam (Qualification Round 2014) ] A. Magic Trick
Problem A. Magic Trick Small input6 points You have solved this input set. Note: To advance to the ...
- [C++]Store Credit——Google Code Jam Qualification Round Africa 2010
Google Code Jam Qualification Round Africa 2010 的第一题,很简单. Problem You receive a credit C at a local ...
- [C++]Saving the Universe——Google Code Jam Qualification Round 2008
Google Code Jam 2008 资格赛的第一题:Saving the Universe. 问题描述如下: Problem The urban legend goes that if you ...
随机推荐
- Hbse的读写过程
1.Hbase的读取过程. 以读取test_region表,row key为this is row value 400000为例. 1: 到zookeeper中去读取/hbase/root-regio ...
- VB.NET 小程序 2
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ...
- 未能加载文件或程序集“Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad
遇到这个报错是在服务器上的,将一个网站发布到服务器.在本地的运行时正常的,但在服务器上是报错的. 原因是服务器上是没有安装Microsoft.Web.Infrastructure.然而,处理这个问题也 ...
- vs 2015密钥
专业版:HMGNV-WCYXV-X7G9W-YCX63-B98R2企业版:HM6NR-QXX7C-DFW2Y-8B82K-WTYJV
- 调用支付宝PHP接口API实现在线即时支付功能(UTF-8编码)
这次在项目中要实现订单功能,所以要完成在线支付,在线支付一般有网银支付和第三方支付(支付宝.paypal等)这两种途径,未简单起见,先完成支付宝在线支付功能,由于项目基于Yii框架,且使用UTF-8编 ...
- 单一职责原则(SRP)
一个类应仅有一个引起它变化的原因. 内聚性. 每个Responsibility都是变化的一个轴线.当需求变化时,该变化会反映为类的职责的变化 当一个类耦合了多个职责时,一个职责的变化会消弱或抑制其他职 ...
- 数据挖掘:实用机器学习技术P295页:
数据挖掘:实用机器学习技术P295页: 在weka软件中的实验者界面中,新建好实验项目后,添加相应的实验数据,然后添加对应需要的分类算法 ,需要使用多个算法时候重复操作添加add algorithm. ...
- IntellijIDEA 使用技巧
1:显示工具栏目 toolbar:view ->ToolBar 2:加载源码 new project ->选择java project ->选择源码所在目录 ->ok
- 完美解决fixed 水平居中问题
群里的朋友问的,发现自己没写过:就写了下,原理和网上的fixed上下左右四个角的原理一样! 1.防止页面振动: body{ _background-image: url(about:blank); _ ...
- C#多线程与UI响应 跨线程更新UI
最近在写一个TCP通信程序,自定义了一个通信类TCPclient,用于客户端异步接收和发送网络消息. TCPclient中定义了一个接收到新的网络消息事件: //收到新消息事件 public dele ...