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 ...
随机推荐
- Mysql笔记5之查询
1查询所有的列 select *from student 2查询指定列 select name,age from student 3查询时候使用别名 select name as 别名,age as ...
- JavaEE程序编码规范
JavaEE程序编码规范 目 录 JAVA程序编码规范1 1变量的命名规则1 1.1常量(包含静态的)1 1.2类变量(静态变量)及实例变量1 1.3局部变量1 1.4参数2 1.5其它2 2方法 ...
- java工程开发之图形化界面之(第四课)
本节中,我们将创建一个小应用程序,它使用循环生成其图案.我们将使用if语句和setColor方法.同时我们将介绍drawString方法,并使用它在小应用程序窗口中写出文本. 下面的小应用程序是显示一 ...
- iis7支持asp(访问页面,页面存在仍然提示404)
1. win7下安装IIS时ASP一般被默认不选中的状态,因此需要打开IIS检查功能视图栏中是否存在ASP选项,若没有则需要从控制面板->程序和 功能->打开或关闭Windows功能-&g ...
- tcp 重组原理
原文: http://blog.chinaunix.net/uid-21768364-id-4823449.html 1 .引言TCP/IP 协议现在已经广泛的被应用.数据在网络上应用 TCP/IP ...
- 用JavaScript 来将数字转换成字符。
背景: 一切嵌入式设备上面的信息,比如设备名称,设备时区是可以写入到设备上面的寄存器中的(一个寄存器两个字节,2*8 bit),比如 -1 ,写入到寄存器中为 2d31,然后可以通过一些进程将寄存器中 ...
- angularJs关于指令的一些冷门属性
我们使用ng的时候,经常会使用到指令,大家所熟知的属性我在这里就不介绍了,讲讲大家没怎么留意的属性 1.multiElement 这是指定指令作用区间的功能,最常用的就是ng-repeat-start ...
- ios复制到剪贴板
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #000000 } p.p2 { margin: 0.0px 0. ...
- 分享我们项目中基于EF事务机制的架构 【转载】
http://www.cnblogs.com/leotsai/p/how-to-use-entity-framework-transaction-scope.html 写在前面: 1. 本文中单元测试 ...
- 如何创建一个要素数据类 IField,IFieldEdit,IFields,IFieldsEditI,GeometryDef,IGeometryDefEdit接口
如何创建一个要素数据类 创建要素类用到了IFeatureWorkspace.CreateFeatureClass方法,在这个方法中有众多的参数,为了满足这些参数,我们要学习和了解下面的接口. IFie ...