今天有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 报告的更多相关文章

  1. 【面试题】Round A China New Grad Test 2014总结

    我也有够懒的,今天才跑来写总结,自觉面壁中… 上一篇是Practice Round,今天是Round A,五道题. 每次做完都想说,其实题不难..但在做的过程中总是会各种卡,只有自己一行一行实现了,才 ...

  2. Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告

    Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...

  3. CH Round #56 - 国庆节欢乐赛解题报告

    最近CH上的比赛很多,在此会全部写出解题报告,与大家交流一下解题方法与技巧. T1 魔幻森林 描述 Cortana来到了一片魔幻森林,这片森林可以被视作一个N*M的矩阵,矩阵中的每个位置上都长着一棵树 ...

  4. Codeforces Round 319 # div.1 & 2 解题报告

    Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...

  5. Codeforces Round #231 (Div2) 迟到的解题报告

    题目A: 给一个火柴等式,可以从左边移动一根到右边,也可以从右边移到左边,但是不能移动“+”,”=“的火柴, 而且加法里面的数都要大于0(很重要的条件),基本上注意到这点的都过了,没注意的都被HACK ...

  6. CodeForce---Educational Codeforces Round 3 The best Gift 解题报告

    对于这题笔者认为可以用数学排列来算,但是由于笔者很懒所以抄了一段大神的代码来交个大家了, 这位大神的基本想法就是通过记录各类书的数量,再暴力破解: 下面贴出这位大神的代码吧: #include< ...

  7. Codeforces Round #232 (Div. 1) A 解题报告

    A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...

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

  9. Kickstart Practice Round 2017---A

    Problem The Constitution of a certain country states that the leader is the person with the name con ...

随机推荐

  1. realypay

    1.判断新老接口的方法: 去网站后台接口配置的地方,如果有merchantno参数就是新接口,否则为老接口,新接口则不需要更新了. 2.老接口需要去网站后台卸载老的接口,然后再用新的(下载的文件)覆盖 ...

  2. java文件处理之压缩,分割

    http://blog.csdn.net/ycg01/article/details/1366648 java文件处理之压缩,分割 标签: javaexceptionimportnullbytefil ...

  3. 解决:无法将“Add-Migration”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次

    1.输入的中划线“-”格式不对,检查是否为全角状态下输入,误输入了下划线“_",或是前后有空格: 2.没有引用EntityFramework命令,请执行如下名称(Import-Module ...

  4. STM32 IAP 固件升级设计/U盘升级固件

    源:STM32 IAP 固件升级设计/U盘升级固件 固件升级的基本思路是: 将stm32 的flash划分为两个区域: 1.Bootloader区:存放bootloader的代码,bootloader ...

  5. UIApearance

    转载自:http://www.cocoachina.com/ios/20150723/12671.html 文章开头先援引一下Mattt Thompson大神在UIApearance里的一句话吧: 1 ...

  6. VMware NAT端口映射外网访问虚拟机linux

    本文目的: 一. SSH连接 二. 访问HTTP VMware Workstation提供了两种虚拟机上网方式,一种bridge,一种NAT,bridge可以获得公网地址,而NAT只能是内网地址了. ...

  7. Mahout分布式运行实例:基于矩阵分解的协同过滤评分系统(一个命令实现文件格式的转换)

     Apr 08, 2014  Categories in tutorial tagged with Mahout hadoop 协同过滤  Joe Jiang 前言:之前配置Mahout时测试过一个简 ...

  8. 在CentOS中安装jenkins

    一.检查java是否安装 $ java -version java version "1.6.0_22" OpenJDK Runtime Environment (IcedTea6 ...

  9. git 以及 github 使用系列

    本人打算开始写一个有关git 使用,以及github 使用的系列文章了,一来可以自己总结,二来github用好了,可以存放自己的一些知识框架吧. 1.准备 : 有一个 github上的账号, wind ...

  10. 【HighCharts系列教程】八、Html标签属性——Labels

    一.labels属性说明 Labels属性允许在HighCharts图表的任意位置添加任意的html代码.可以实现许多自定义内容. 二.labels属性详解 参数 子参数 说明 默认值 items — ...