Google Code Jam 2011 (Qualification)

书接上篇

1. [84%/98%] Bob Trust: 两个机器人并行依次按钮

由于要依次按钮,所以并行能节省的时间,只有另外一个机器人移动的时间,而它按钮的那一秒钟是不能节省的。

2. [87%/82%] Magicka:依次合并或者清除元素

由于即使是大数据集,合并列表和冲突列表个数也不过36和28,所以最好直接把这两个列表反向来进行匹配,而不是在后面的匹配测试中去正反测试两遍。
另外注意先合并,后判冲突。

3. [90%/85%] Candy Splitting:加法改异或

按题目叙述,不难发现Patrick的错误加法真值表与异或XOR运算相同。由于没有进位,可以单独看每个二进制位。
如果某一个二进制位上,1的个数为奇数,则无论如何划分,都不可能使得最后异或结果相等。
如果1的个数为偶数,则可以任意划分,但需要保证可怜的Patrick至少分到一个糖果。
所以排序后取最小的数给Patrick,其他的全部留给Sean。

4. [58%/97%] GoroSort:概率排序

首先注意,下面这个Smallest的条件很容易被忽略掉:
The second line of each test case will contain a permutation of the N smallest positive integers.

然后由于每个数都已经知道最后需要所在的位置,所以排除掉已经在目标位置的情况,其他的每hit一次,有1/2的机会回到正常的位置,再加上,占据现有位置的那个数,以后会有1/2的机会回到它自己的位置,所以只需要每个不在目标位置的数上累计加一就能得出结果。

这题最挨打的,就是那个%.6lf。 我是用整数表示,然后后面加6个0。这个实在太误导了,让人以为会计算很复杂的概率。

PS 最后,这次的GCJ Command Line Tool还蛮好用的,呵呵~

GCJ 2011 Qualification Round Solution Download

CIFM China Alpha

钊色推荐的基金一直定投到现在,年均获利都在15%~20%左右。虽然前不久上投出了丑闻,但也不影响定投的回报。所以说定投真是个好东西,唯一的弊端就是钱不够灵活,你得有耐心一直等到盈利再卖,而且你得有胆量越跌越买。

其实,说穿了,你只需要扔那儿不管他就行了,反正每个月自动扣钱。至于你设置每个月什么时候扣钱,见仁见智,也许没啥规律可循。

闲来无事,还是忍不住从Google财经拉了些上投阿尔法的数据下来,算了下每天的算术平均值(虽然有更复杂的算法,例如考虑不同月份的权重,或者根据过往数据,自动学习规律建模),但定投本来原理就在于平均,所以也许这样效果已经足够令人满意了。

CIFM China Alpha
CIFM China Alpha

从图上看来,每月1号买是个不错的选择,但定投经常会有时延,如果延到了3、4号,就霉了。我目前的25日发工资,26日买也不错,而且27,28的数据也还行,所以结论就是不用改了…:P

PS:  BeautifulSoup的作者对于他这个咚咚的兴趣已然失去,所以目前为止,Python 3的HTML Parser + Tree Walker还有待新兴之星。下面这个脚本只是临时自用而已,很瓜的用正则析数据…

Python 脚本

What’s wrong with BuzzCounter?

在自己的Blog上展示Buzz,以前一直用的BuzzCounter提供的服务,但BuzzCounter最近开始出问题, 始终显示很老的buzz,不能更新,加之他本来有的一些其他的问题,比如:1. 有广告贴;2. 贴子是通过他服务器中转的,而不是从客户浏览器直接去Google取的。

再加上Google Buzz API现在也RESTful了,更好的是,还支持JSONP,跨域的问题也解决了,所以还是觉得自己写一个比较好。

参见侧边栏和附件,Google ID在buzz.js里的第一行就可以设置。至于颜色、外观啥的,自己改改buzz.css吧。

当然,前提是你的Buzz是Public的。

附件:aXqd Buzz

三悼谷歌

上一篇文章:https://blog.axqd.net/2010/03/23/mourn-again/

Google an update on china

Ever since we launched Google.cn, our search engine for mainland Chinese users, we have done our best to increase access to information while abiding by Chinese law. This has not always been an easy balance to strike, especially since our January announcement that we were no longer willing to censor results on Google.cn.

We currently automatically redirect everyone using Google.cn to Google.com.hk, our Hong Kong search engine. This redirect, which offers unfiltered search in simplified Chinese, has been working well for our users and for Google. However, it’s clear from conversations we have had with Chinese government officials that they find the redirect unacceptable—and that if we continue redirecting users our Internet Content Provider license will not be renewed (it’s up for renewal on June 30). Without an ICP license, we can’t operate a commercial website like Google.cn—so Google would effectively go dark in China.

That’s a prospect dreaded by many of our Chinese users, who have been vocal about their desire to keep Google.cn alive. We have therefore been looking at possible alternatives, and instead of automatically redirecting all our users, we have started taking a small percentage of them to a landing page on Google.cn that links to Google.com.hk—where users can conduct web search or continue to use Google.cn services like music and text translate, which we can provide locally without filtering. This approach ensures we stay true to our commitment not to censor our results on Google.cn and gives users access to all of our services from one page.

Over the next few days we’ll end the redirect entirely, taking all our Chinese users to our new landing page—and today we re-submitted our ICP license renewal application based on this approach.

As a company we aspire to make information available to users everywhere, including China. It’s why we have worked so hard to keep Google.cn alive, as well as to continue our research and development work in China. This new approach is consistent with our commitment not to self censor and, we believe, with local law. We are therefore hopeful that our license will be renewed on this basis so we can continue to offer our Chinese users services via Google.cn.

Posted by David Drummond, SVP, Corporate Development and Chief Legal Officer

关于谷歌中国的最新声明

2010 年 6 月 28 日

David Drummond, SVP, Corporate Development and Chief Legal Officer

自从为中国大陆用户推出 Google.cn 这个 搜索引擎以来,我们一直在尽最大的努力来提高用户对信息的访问,同时遵守中国法律。做到这样的平衡并不容易,尤其是我们在今年1月份宣布不愿意继续在 Google.cn 上对搜索结果进行审查。

当前,我们把所有访问 Google.cn 的用户自动指向了我们香港的搜索引擎 Google.com.hk,通过这种方法,我们可以提供未经审查的简体中文 搜索结果。目前这种方法无论对用户还是对 Google 都运行良好。然而,在与中国有关部门的沟通中我们明确获知:自动指向的做法是不可接受的。如果我们继 续进行自动指向,我们的 ICP 牌照将无法通过年检(年检截止时间是6月30日)。没有 ICP 牌照,我们将不能在中国运营 Google.cn 这样的商业网站——这意味着 Google.cn 将不能被访问。

那是许多 Google 中国用户所担忧的结果,因为他们都清楚表明了希望 Google.cn 继续运营的愿望。为此,我们开始寻找其他可能的替代办法,我们开始为一小部分用户提供一个新的 google.cn 访问页面,该页面与 Google.com.hk 链接,在那里,用户可以进行搜索,或继续使用在 google.cn 上的音乐搜索(Music Search)和文本翻译(Translate)等不涉及内容审查的服务。这个新做法确保 Google.cn 不对搜索结果进行审查的承诺,同时让用户可以在一个页面上访问我们所有的服务。

未来几天,我们将全部停止自动指向,让所有中国用户都直接访问这个新页面——今天,基于这样一个新页面,我们重新提交了 ICP 牌照年检申请。

作为一家公司,我们的追求是让用户随时随地访问到他们所需的信息,包括中国的用户。这就是为什么我们一直在努力地保持 Google.cn 的运营,以及继续我们在中国的研发工作。这个新做法确保了 Google.cn 不对搜索结果进行审查的承诺,并且,我们相信,符合中国法律。因此我们希望能够通过 ICP 牌照年检,让我们可以继续通过 Google.cn 为中国用户提供服务。

再悼谷歌

上一篇文章:https://blog.axqd.net/2010/01/13/mourn/

A new approach to China: an update

On January 12, we announced on this blog that Google and more than twenty other U.S. companies had been the victims of a sophisticated cyber attack originating from China, and that during our investigation into these attacks we had uncovered evidence to suggest that the Gmail accounts of dozens of human rights activists connected with China were being routinely accessed by third parties, most likely via phishing scams or malware placed on their computers. We also made clear that these attacks and the surveillance they uncovered—combined with attempts over the last year to further limit free speech on the web in China including the persistent blocking of websites such as Facebook, Twitter, YouTube, Google Docs and Blogger—had led us to conclude that we could no longer continue censoring our results on Google.cn.

So earlier today we stopped censoring our search services—Google Search, Google News, and Google Images—on Google.cn. Users visiting Google.cn are now being redirected to Google.com.hk, where we are offering uncensored search in simplified Chinese, specifically designed for users in mainland China and delivered via our servers in Hong Kong. Users in Hong Kong will continue to receive their existing uncensored, traditional Chinese service, also from Google.com.hk. Due to the increased load on our Hong Kong servers and the complicated nature of these changes, users may see some slowdown in service or find some products temporarily inaccessible as we switch everything over.

Figuring out how to make good on our promise to stop censoring search on Google.cn has been hard. We want as many people in the world as possible to have access to our services, including users in mainland China, yet the Chinese government has been crystal clear throughout our discussions that self-censorship is a non-negotiable legal requirement. We believe this new approach of providing uncensored search in simplified Chinese from Google.com.hk is a sensible solution to the challenges we’ve faced—it’s entirely legal and will meaningfully increase access to information for people in China. We very much hope that the Chinese government respects our decision, though we are well aware that it could at any time block access to our services. We will therefore be carefully monitoring access issues, and have created this new web page, which we will update regularly each day, so that everyone can see which Google services are available in China.

In terms of Google’s wider business operations, we intend to continue R&D work in China and also to maintain a sales presence there, though the size of the sales team will obviously be partially dependent on the ability of mainland Chinese users to access Google.com.hk. Finally, we would like to make clear that all these decisions have been driven and implemented by our executives in the United States, and that none of our employees in China can, or should, be held responsible for them. Despite all the uncertainty and difficulties they have faced since we made our announcement in January, they have continued to focus on serving our Chinese users and customers. We are immensely proud of them.

Posted by David Drummond, SVP, Corporate Development and Chief Legal Officer

关于谷歌中国的最新声明

David Drummond, SVP, Corporate Development and Chief Legal Officer

今年1月12日,我们在本博客上宣布,Google及另外二十余家美国公司受到了来自中国的、复杂的网络攻击,在对这些攻击进 行深入调查的过程中,通过我们所收集到的证据表明,几十个与中国有关的人权人士的Gmail帐号定期受到第三方的侵入,而这大部分侵入是通过安装在他们电脑上的钓鱼软件或恶意软件进行的。这些攻击以及它们所暴露的网络审查问题,加上去年以来中国进一步限制网络言论自由,包括 对FaceBook、Twitter、YouTube、Google Docs 和 Blogger 等网站的持续屏蔽,使我们做出结论:我们不能继续在Google.cn搜索结果上进行自我审查。

从今天早上开始,我们已停止了在Google.cn搜索服务上的自我审查,包括 Google Search (网页搜索)、Google News(资讯搜索)和Google Images (图片搜索)。 访问 Google.cn 的用 户从现在开始将被指向Google.com.hk,在这个域名上,我们将提供未经审查的简体中文搜索结果,这些为中国大陆用户设计的服务将通过我们在香港的服务器实现。香港地区的用户还将继续通过Google.com.hk获得跟现在一样的、未经审查的繁体中文搜索服务。在我们进行迁移的过程中,由于香港服务器负荷的增加以及这些变化的复杂程度,用户可能会发现搜索速度变慢,或发现某些产品暂时不能访问。

实施我们做出的在Google.cn上停止审查搜索结果的承诺是一个十分艰难的过程。我们希望全球尽可能多的用户都能访问到我们的服务,包括在中国大陆的用户。中国政府在与我们讨论的过程中已经十分明确地表示,自我审查是一个不可谈判的法律要求。为此,我们相信,一个解决我们所面临挑战的可行方案是在Google.com.hk上提供未经审查的简体中文搜索结果——它完全符合法律要求,同时也有助于提高中国大陆用户对信息的访问。我们十分希望中国政府尊重我们的这一决定,尽管我们知道,用户对Google服务的访问有可能随时被阻止。为此,我们将密切监测网址访问问题,并制作了一个新页面,用户可以实时地了解到在中国哪些Google服务是可用的。

至于Google的广泛的业务运营,我们计划继续在中国的研发工作,并将保留销售团队,然而销售团队的规模显然部分取决于中国大陆用户能否访问Google.com.hk 。最后,我们要清楚表明:所有这些决定都是由美国的管理团队做出和实施的,没有任何一位中国员工能够、或者应该为这些决定负责。自我们在1月份发布博客以 来,尽管面临着众多的不确定性和困难,他们仍然坚守在工作岗位,专注于服务我们的中国用户和客户。我们为拥有这样的员工感到深深的骄傲。

百度应该进军香港么?

百度李彦宏

悼谷歌

A new approach to China

1/12/2010 03:00:00 PM

Like many other well-known organizations, we face cyber attacks of varying degrees on a regular basis. In mid-December, we detected a highly sophisticated and targeted attack on our corporate infrastructure originating from China that resulted in the theft of intellectual property from Google. However, it soon became clear that what at first appeared to be solely a security incident–albeit a significant one–was something quite different.

First, this attack was not just on Google. As part of our investigation we have discovered that at least twenty other large companies from a wide range of businesses–including the Internet, finance, technology, media and chemical sectors–have been similarly targeted. We are currently in the process of notifying those companies, and we are also working with the relevant U.S. authorities.

Second, we have evidence to suggest that a primary goal of the attackers was accessing the Gmail accounts of Chinese human rights activists. Based on our investigation to date we believe their attack did not achieve that objective. Only two Gmail accounts appear to have been accessed, and that activity was limited to account information (such as the date the account was created) and subject line, rather than the content of emails themselves.

Third, as part of this investigation but independent of the attack on Google, we have discovered that the accounts of dozens of U.S.-, China- and Europe-based Gmail users who are advocates of human rights in China appear to have been routinely accessed by third parties. These accounts have not been accessed through any security breach at Google, but most likely via phishing scams or malware placed on the users’ computers.

We have already used information gained from this attack to make infrastructure and architectural improvements that enhance security for Google and for our users. In terms of individual users, we would advise people to deploy reputable anti-virus and anti-spyware programs on their computers, to install patches for their operating systems and to update their web browsers. Always be cautious when clicking on links appearing in instant messages and emails, or when asked to share personal information like passwords online. You can read more here about our cyber-security recommendations. People wanting to learn more about these kinds of attacks can read this U.S. government report (PDF), Nart Villeneuve’s blog and this presentation on the GhostNet spying incident.

We have taken the unusual step of sharing information about these attacks with a broad audience not just because of the security and human rights implications of what we have unearthed, but also because this information goes to the heart of a much bigger global debate about freedom of speech. In the last two decades, China’s economic reform programs and its citizens’ entrepreneurial flair have lifted hundreds of millions of Chinese people out of poverty. Indeed, this great nation is at the heart of much economic progress and development in the world today.

We launched Google.cn in January 2006 in the belief that the benefits of increased access to information for people in China and a more open Internet outweighed our discomfort in agreeing to censor some results. At the time we made clear that “we will carefully monitor conditions in China, including new laws and other restrictions on our services. If we determine that we are unable to achieve the objectives outlined we will not hesitate to reconsider our approach to China.”

These attacks and the surveillance they have uncovered–combined with the attempts over the past year to further limit free speech on the web–have led us to conclude that we should review the feasibility of our business operations in China. We have decided we are no longer willing to continue censoring our results on Google.cn, and so over the next few weeks we will be discussing with the Chinese government the basis on which we could operate an unfiltered search engine within the law, if at all. We recognize that this may well mean having to shut down Google.cn, and potentially our offices in China.

The decision to review our business operations in China has been incredibly hard, and we know that it will have potentially far-reaching consequences. We want to make clear that this move was driven by our executives in the United States, without the knowledge or involvement of our employees in China who have worked incredibly hard to make Google.cn the success it is today. We are committed to working responsibly to resolve the very difficult issues raised.

Posted by David Drummond, SVP, Corporate Development and Chief Legal Officer

关于Gmail怨念的附件下载

在Gmail下载了马莞迪的一个附件,同时生成了两个文件,CAG6D4B.和CAG6D4B,改任意一个后缀为DOC后正常浏览,后删除二者,结果只删掉一个,还剩下了一个CAG6D4B.,说找不到文件…

于是怨念的旅程便开始了,先试了各种方法删除之:

在win下查看属性,隐藏和只读,分别改之,提示找不到文件

Dos下:

del /F /ARH ...提示找不到文件
Attrib -rh ...提示找不到文件
ren ... 提示找不到文件

现在意识到问题的严重性,而且听说季翔也不幸中招…..上网查资料,各大Blog,论坛很多地方有和我一样的问题,但是没有任何有用的回复(有人说安全模式下可以删除,结果小白的跑去试,当然不行,提示找不到文件)

接着采用原来屡试不爽的杀手锏:

del. file-pathfile-name... 提示找不到文件

当然再接下来就是国外的网站,因为感觉这些BT的咚咚老外老是厉害一点(应该不算崇洋媚外吧)结果发现根本没有这个问题的内容(后来才发现此问题大概只出现在Gmail处理中文附件的时候,所以老外大概没有机会碰上吧)

至此我已彻底无语,剩下的路不多了:

配ServU将路径指向桌面,然后用FTPRush删除之,提示成功,但没有删除

又发现国内某论坛有人对此有所深入探究,引用如下:

“我在同目录里(桌面)又建立了一个名叫“CAJUWNF5”的文件,名字一样但没有那个点儿。再删除原先那个“CAJUWNF5.”时,轻松成功。然而,新建立这个“CAJUWNF5”却删不掉了。现在它的文件名里没有了点,仍删不掉,也照样不能改名或移动。 ”

唉,他这个想法就比较BT,不过还是没有解决问题,但是倒让人很生疑惑,文中他还提到:

“更糟的是,我又重复了一次原先的操作(从gmail中保存附件),想看看是怎么回事。现在,我的桌面上有两块橡皮膏了。”(我也是这样…)

“毛病出在文件名末尾的“.”上。似乎这个点让NTFS在判别文件时产生了什么循环,以致找不到文件。要是FAT,碰到这种文件,用扇区读写工具(比如 debug)进入分区表,手工就能解决。不知NTFS有没有类似的办法。 ”(想来要是FAT,我也不会用debug改分区表…)

本来想就此打住,上各大论坛发帖询问,结果突然看见了任务栏上196的远程SecureCRT连接,想象要是在linux下用rm -rf说不定可以干掉,说干就干:

配共享,开防火墙(天网,Microsoft,IBM)终于在196上smbclient -L 202.115.22.*看到了桌面的共享,然后rm -rf …轻松干掉

有的时候还是感觉linux好阿

关于google的网页快照

使用过google的人都有一个感觉,爽!

但是有时也不是那么的爽,比如:虽然所有result下面都有网页快照,但从来都打不开(这样的坏处是:有时候result的连接已经失效了,但是明明看到下面节选里面有自己想要的内容,却看不完,这种问题本来可以通过网页快照解决的)

举个例子:

http://64.233.167.104/search?q=cache:JF2VBe-v3KQJ:a.wholelottanothing.org/+nothing&hl=zh-CN

上面就是一个网页快照的连接(搜nothing显示的第一个链接的网页快照),返回Connection reset by peer

怎么办啊,怎么办?

在网上找了找解决办法

如下:

http://64.233.167.104/search?god=axqd&q=cache:JF2VBe-v3KQJ:a.wholelottanothing.org/+nothing&hl=zh-CN

怎么样,打开了吧,呵呵,不要问我为什么,其实只要url里面不要包含“search?q=”字段就行了,上面再其中嵌入“god=axqd”就是为了把“search?q=”伸开!

以后可以尽情享受google的网页快照功能了吧!