快一年没有做题了, 今天跟了一下 GCJ Round 1A的题目, 感觉难度偏简单了, 很快搞定了第一题, 第二题二分稍微考了一下, 还剩下一个多小时, 没仔细想第三题, 以为 前两个题目差不多可以晋级了. 切出去玩了一会, 大概剩半小时, 发现自己的排名逐渐快超 1k了, 果断决定搞出第三题的小数据. 然后简单的O(n^3)的枚举过了. 然后有惊无险的晋级了.

第一题,读懂题目,然后计算就很好说了. 第二题,计算最小公倍数的那种肯定是行不通的, 二分 t时刻 已经剪完了多少个, 正在剪的有多少个, 然后准备剪的有多少个, 然后二分.

第三题, 其实当时已经想到了解决思路, 去掉点然后没有凸包就意味着极角排序之后, 删掉多少个中间元素, 可以让某两个极角序列的interval 大于 Pi. 复杂度就是 O(n^2lgn) nlgn是极角排序负责度, n是枚举每一个需要处理的点.

  1. 1: #include <bits/stdc++.h>
  1. 2: using namespace std;
  1. 3:  
  1. 4: int n;
  1. 5: double x[3001], y[3001];
  1. 6: double pi = atan(1) * 4;
  1. 7:  
  1. 8: int solve(vector <double> lis)
  1. 9: {
  1. 10: if(n == 1)
  1. 11: return 0;
  1. 12: lis.push_back(100);
  1. 13: int p = 0;
  1. 14: int ret = 1000000;
  1. 15: for(int i = 0; i < n; i++)
  1. 16: {
  1. 17: while(lis[p+1] <= lis[i] + pi - 1e-8)
  1. 18: p ++;
  1. 19: ret = min(ret, p - i);
  1. 20: }
  1. 21: return ret;
  1. 22: }
  1. 23:  
  1. 24: void solve()
  1. 25: {
  1. 26: cin >> n;
  1. 27: cout << endl;
  1. 28: for(int i = 1; i <= n; i++)
  1. 29: {
  1. 30: cin >> x[i] >> y[i];
  1. 31: }
  1. 32: for(int i = 1; i <= n; i++)
  1. 33: {
  1. 34: vector <double> dir;
  1. 35: for(int j = 1; j <= n; j++)
  1. 36: if(i != j)
  1. 37: {
  1. 38: double v = atan2(y[j] - y[i], x[j] - x[i]);
  1. 39: dir.push_back(v);
  1. 40: dir.push_back(v + 2 * pi);
  1. 41: }
  1. 42: sort(dir.begin(), dir.end());
  1. 43: cout << solve(dir) << endl;
  1. 44: }
  1. 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 题解的更多相关文章

  1. Google Code Jam 2015 R1C B

    题意:给出一个键盘,按键都是大写字母.给出一个目标单词和一个长度L.最大值或者最大长度都是100.现在随机按键盘,每个按键的概率相同. 敲击出一个长度为L的序列.求该序列中目标单词最多可能出现几次,期 ...

  2. Google Code Jam 2015 R2 C

    题意:给出若干个句子,每个句子包含多个单词.确定第一句是英文,第二句是法文.后面的句子两者都有可能.两个语种会有重复单词. 现在要找出一种分配方法(给每个句子指定其文种),使得既是英文也是法文的单词数 ...

  3. Google Code Jam 2014 Qualification 题解

    拿下 ABD, 顺利晋级, 预赛的时候C没有仔细想,推荐C题,一个非常不错的构造题目! A Magic Trick 简单的题目来取得集合的交并 1: #include <iostream> ...

  4. [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) ...

  5. [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) ...

  6. [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 ...

  7. [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 ...

  8. [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 ...

  9. [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 ...

随机推荐

  1. TortoiseSVN 更新时忽略指定文件夹

    命令行可以这么来svn update –set-depth=exclude 文件夹 那么TortoiseSVN客户端呢?在文件夹右键中的”更新至版本(U)”更新深度选”排除”,确定,搞定下次更新就不会 ...

  2. 学习笔记2:前端PS切图

    前端PS切图 一.Photoshop的界面设置 二.Photoshop的基本操作 三.Photoshop的传统切图 四.Photoshop的精准切图 五.Photoshop的扩展知识 视频学习:htt ...

  3. Bootstrap 基本用法(续)

    在bootstrap中有很多的组件,这些组件可以帮组我们更快的写出一些好看的样式,下面就是一些样式: 导航框: <ul class="nav nav-tabs"> &l ...

  4. 2014.10.09 Andrew 学习 WPF(刘铁锰) 笔记分享

    引言 主要是讲了关于WPF只是表现层的工具. 第一章: XAML : 可扩张应用程序标记语言    Extensible Application Markup Language 什么是XAML?  X ...

  5. chromium浏览器开发系列第二篇:如何编译最新chromium源码

    说一下为什么这么晚才发第二篇,上周和这周department的工作太多了,晚上都是十点半从公司出发,回家以后实在没有多余的精力去摸键盘了.所以请大家包涵! 上期回顾: chromium源码下载: 1. ...

  6. Centos中安装PHP的PDO MySQL扩展的教程

    PHP Data Objects(PDO)扩展为 PHP 访问数据库定义了一个轻量级的一致接口.实现 PDO 接口的每个数据库驱动可以公开具体数据库的特性作为标准扩展功能.注意利用 PDO 扩展自身并 ...

  7. Hadoop集群“WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable”解决办法

    Hadoop集群部署完成后,经常会提示 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platfo ...

  8. 兼容IE,chrome 等所有浏览器 回到顶部代码

    今天在博客园看到一片帖子回到顶部代码,索性就看了下,但是发现在非IE浏览器下可以运行,在IE浏览器下却运行不了. 故将其代码搬弄过来做了些许修改后,完美支持了IE下的运行. 主要实现功能代码文件: & ...

  9. java面试题小全

    面向对象的特征有哪些方面   1. 抽象:抽象就是忽略一个主题中与当前目标2. 无关的那些方面,3. 以便更充分地注意与当前目标4. 有关的方面.抽象并不5. 打算了解全部问题,而6. 只是选择其中的 ...

  10. Base64加密

    实际开发中可能需要使用到可解密的加密方式,例如客户端记住用户的密码,客户端不能记住明文密码,那就需要对明文密码进行加密,然后在表单提交之后先对密码进行解密,在进行MD5加密和数据库中的密码进行比较实现 ...