Practice Round China New Grad Test 2014 报告
今天有Google of Greater China Test for New Grads of 2014的练习赛,主要是为了过几天的校园招聘测试做练习用的,帮助熟悉平台,题目嘛,个人觉得除了A题外,B和C就是练习基本编程的。
A题:Bad Horse二分图判定问题。话说昨晚刚简单看了一下代码,写都没写过,只好翻书抄代码了...还是有点幸运的,如果昨天没看,这个题估计就要留白了...感觉还有好多东西没学啊...
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <map>
using namespace std;
#define MAXN 100*2+10 map<string, int> node;
vector<int> G[MAXN];
int color[MAXN]; void create_node(string s)
{
if (!node.count(s))
{
int t = node.size() + ;
node[s] = t;
}
} bool bipartite(int u)
{
for (int i = ; i < G[u].size(); i++)
{
int v = G[u][i];
if (color[v] == color[u]) return false;
if (!color[v])
{
color[v] = - color[u];
if (!bipartite(v)) return false;
}
}
return true;
}
int main()
{
#ifdef LOCAL
//freopen("in", "r", stdin);
freopen("A-small-2-attempt0.in", "r", stdin);
freopen("A-small-2.out", "w", stdout);
#endif
int T;
scanf("%d", &T);
for (int kase = ; kase <= T; kase++)
{
int n;
scanf("%d", &n);
node.clear();
for (int i = ; i < MAXN; i++)
G[i].clear();
for (int i = ; i < n; i++)
{
string name1, name2;
cin >> name1 >> name2;
create_node(name1);
create_node(name2);
G[node[name1]].push_back(node[name2]);
G[node[name2]].push_back(node[name1]);
}
memset(color, , sizeof(color));
color[] = ;
if (bipartite()) printf("Case #%d: Yes\n", kase);
else printf("Case #%d: No\n", kase);
}
return ;
}
B题:Captain Hammer
关于抛物线的,给一物体的初速度和要抛的距离,计算抛出时与水平线的最小夹角。直接套公式。
#include <cstdio>
#include <cmath>
#define PI 3.1415926 int main()
{
#ifdef LOCAL
//freopen("in", "r", stdin);
freopen("B-small-attempt0.in", "r", stdin);
freopen("B-small.out", "w", stdout);
#endif
int T;
scanf("%d", &T);
for (int kase = ; kase <= T; kase++)
{
int v, d;
scanf("%d%d", &v, &d);
double t = (d*9.8) / (*v*v);
double angle = asin(*t);
double ans = angle / PI * / ;
printf("Case #%d: %.7lf\n",kase, ans);
}
return ;
}
C题:Moist
给n个字符串,对第i个字符串作如下判断:该字符串前面(包括本身)是否有序,如果无序,对前i个字符串排序。最后统计排序的次数。
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std; string str[]; int main()
{
#ifdef LOCAL
//freopen("in", "r", stdin);
freopen("C-small-2-attempt0.in", "r", stdin);
freopen("C-small-2.out", "w", stdout);
#endif
int T;
scanf("%d", &T);
for (int kase = ; kase <= T; kase++)
{
int n;
scanf("%d", &n);
getchar();
for (int i = ; i < n; i++)
getline(cin, str[i]);
int cnt = ;
for (int i = ; i < n; i++)
if (str[i] < str[i-])
{
cnt++;
sort(str, str+i+);
}
printf("Case #%d: %d\n", kase, cnt);
}
return ;
}
做第一题的时候感觉时间有些紧张,因为要在四分钟内改一下文件的重定向还要提交(练习都是Small Input),后来就把东西写好了再下载输入文件^_^。其实正常时间还是足够的,不过还是有一次不小心写错文件名,结果得到一个空的输出文件,只能眼睁睁地看着倒计时变为0...
Practice Round China New Grad Test 2014 报告的更多相关文章
- 【面试题】Round A China New Grad Test 2014总结
我也有够懒的,今天才跑来写总结,自觉面壁中… 上一篇是Practice Round,今天是Round A,五道题. 每次做完都想说,其实题不难..但在做的过程中总是会各种卡,只有自己一行一行实现了,才 ...
- Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告
Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...
- CH Round #56 - 国庆节欢乐赛解题报告
最近CH上的比赛很多,在此会全部写出解题报告,与大家交流一下解题方法与技巧. T1 魔幻森林 描述 Cortana来到了一片魔幻森林,这片森林可以被视作一个N*M的矩阵,矩阵中的每个位置上都长着一棵树 ...
- Codeforces Round 319 # div.1 & 2 解题报告
Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...
- Codeforces Round #231 (Div2) 迟到的解题报告
题目A: 给一个火柴等式,可以从左边移动一根到右边,也可以从右边移到左边,但是不能移动“+”,”=“的火柴, 而且加法里面的数都要大于0(很重要的条件),基本上注意到这点的都过了,没注意的都被HACK ...
- CodeForce---Educational Codeforces Round 3 The best Gift 解题报告
对于这题笔者认为可以用数学排列来算,但是由于笔者很懒所以抄了一段大神的代码来交个大家了, 这位大神的基本想法就是通过记录各类书的数量,再暴力破解: 下面贴出这位大神的代码吧: #include< ...
- Codeforces Round #232 (Div. 1) A 解题报告
A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...
- Kickstart Practice Round 2017 Google
Problem B. Vote A and B are the only two candidates competing in a certain election. We know from po ...
- Kickstart Practice Round 2017---A
Problem The Constitution of a certain country states that the leader is the person with the name con ...
随机推荐
- HDU 4685 Prince and Princess
强连通分量,看大神的题解才会写的.... http://www.cnblogs.com/kuangbin/p/3261157.html 数据量有点大,第一次Submit 2995ms过的,时限3000 ...
- Notice: ob_end_clean() [ref.outcontrol]: failed to delete buffer. No buffer to delete
解决方法一 @ob_end_clean(); 解决方法二 if(ob_get_contents()) ob_end_clean();
- CF 672 div2 D
http://codeforces.com/contest/672/problem/D 题目大意: 有n个人,每个人有pi的钱,然后可以由如下操作,每次都可以挑选一个最富有的人,把它的钱给最穷的人.但 ...
- 基于ATmgea8单片机设计的加热控制系统(转)
源:http://blog.163.com/zhaojun_xf/blog/static/3005058020085102562729/ 1 引言 温度是工业生产中主要的被控参数之一,与之相关的各种温 ...
- error: QApplication: No such file or directory
尝试用Qt5编译Qt4的工程.你会遇到下面的问题: 错误:C1083: 无法打开包括文件:“QApplication”: No such file or directory 出现原因:Qt5里不再用Q ...
- Android tcpdump抓包应用实现
Android tcpdump抓包应用实现 Android应用很多时候都会涉及到网络,在请求网络出错时,我们可以通过抓包来分析网络请求,返回的数据等,通常我们是用tcpdump这个工具来抓包,再通 ...
- 【BZOj 3670】【UOJ #5】【NOI 2014】动物园
http://www.lydsy.com/JudgeOnline/problem.php?id=3670 http://uoj.ac/problem/5 可以建出"KMP自动机"然 ...
- 学习Redis从这里开始
本文主要内容 Redis与其他软件的相同之处和不同之处 Redis的用法 使用Python示例代码与Redis进行简单的互动 使用Redis解决实际问题 Redis是一个远程内存数据库,它不仅性能强劲 ...
- Spark+ECLIPSE+JAVA+MAVEN windows开发环境搭建及入门实例【附详细代码】
http://blog.csdn.net/xiefu5hh/article/details/51707529 Spark+ECLIPSE+JAVA+MAVEN windows开发环境搭建及入门实例[附 ...
- ajax跨域实现api 接口调用
背景: 想实现跨域去调用接口, 然后同时支持下次调用,能够带cookie信息过来,同时支持来自多个源头的域名的跨域调用. 1.这样支持来自所有域名的跨域调用: 不支持跨域是,浏览器报错: 在api接口 ...