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 ...
随机推荐
- Redis(1)在windows环境下的安装和测试
初次准备使用redis,一个著名的nosql缓存数据库. 这里是第一天,就简单写一下windows下的安装,遇到的一些问题,然后简单的使用和测试,之后会在代码中使用和测试. 之后还会在生产环境中进行测 ...
- Java 学习路线以及各阶段学习书籍,博文,视频的分享
感谢: 感谢每一个打开这篇文章的人,听我在这里瞎扯!至于我为什么会有闲情写这篇文章呢?因为我每天想的是为什么要给我这样的需求,背后的人性是什么,我能再做些什么能让他更好.久而久之,我也稍微有了些自己的 ...
- 微信小程序Server端环境配置
主要内容:1. SSL免费证书申请步骤2. Nginx HTTPS 配置3. TLS 1.2 升级过程 微信小程序要求使用 https 发送请求,那么Web服务器就要配置成支持 https,需要先申请 ...
- 开心的金明<0-1背包>
题意:0-1背包经典题: 不多述,直接上代码: 1.二维数组表示法: #include<cstdio> #include<iostream> #include<algor ...
- 如何做好移动安全(梆梆加固后的APK破解提取dex)
智能手机的普及将移动互联网的发展推到了一个让所有人都为之兴奋的高度,我想即使是以商业眼光见长的“苹果教父”乔布斯也不会料想到短短几年时间,智能手 机就已经成为了所有人离不开的商业产品,各种商业应用层出 ...
- 一个combineInputformat
mark import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import org.apa ...
- Linux基本命令之用户系统相关命令
1.格式说明 [simon@localhost simon]$ [simon@localhost ~]$ 这两种方式表示相同.simon是指定用户,localhost是计算机名字,如果不设置默认为lo ...
- adb shell 命令详解,android
http://www.miui.com/article-275-1.html http://noobjava.iteye.com/blog/1914348 adb shell 命令详解,android ...
- CodeForces 614D Skills
排序+枚举+二分 最大的那些变成A,小的那部分提高最小值 #include<cstdio> #include<cstring> #include<cmath> #i ...
- [转] spring事务管理几种方式
前段时间对Spring的事务配置做了比较深入的研究,在此之间对Spring的事务配置虽说也配置过,但是一直没有一个清楚的认识.通过这次的学习发觉Spring的事务配置只要把思路理清,还是比较好掌握的. ...