今天有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. 用MyEclipse自动生成hibernate映射文件和实体类

    创建数据库,创建相应的表 点击图标,选择MyEclipse Datebase Explorer 右击空白区域,选择new菜单,根据提示创建数据库连接,创建好后会显示你所创建的连接名,如图mysqldb ...

  2. [学习opencv]高斯、中值、均值、双边滤波

    http://www.cnblogs.com/tiandsp/archive/2013/04/20/3031862.html [学习opencv]高斯.中值.均值.双边滤波 四种经典滤波算法,在ope ...

  3. 属性动画ValueAnimator用法

    用法举例: 1. ValueAnimator animator = ValueAnimator.ofInt(0,100);//定义animator 2. animator.addUpdateListe ...

  4. java删除文件夹 Java中实现复制文件或文件夹

    删除文件夹 import java.io.File; public class DeleteDir { /** * @param args */ public static void main(Str ...

  5. zf-关于被发牌人没有显示环节的那个被发牌人的解决办法

    是存储过程里的字段没有插入进去,添加个presonName即可--修改的时候可以执行 dbo.dingshi_fapai 来进行存储 如果添加presonName 必须在临时表里加上这个字段,然后在进 ...

  6. android UI中添加一张图片如何将这张图片中某一部分设为透明的

    可以利用canvas画布类,这个类的具体方法可以参看官方api.http://developer.android.com/reference/android/graphics/Canvas.html ...

  7. java.lang.RuntimeException: java.lang.NoSuchMethodException:

    [java] 15/12/19 14:09:46 INFO mapred.JobClient: Task Id : attempt_201512182036_0017_m_000000_0, Stat ...

  8. MyEclipse10.7使用egit托管项目到GitHub

    原文出处:http://www.xuebuyuan.com/2126438.html 1.注册一个github账户:(www.github.com)点击打开链接 注册完成后,登录github后点击右上 ...

  9. js正则表达式大全(转)

    1. 正则表达式规则 1.1 普通字符 字母.数字.汉字.下划线.以及后边章节中没有特殊定义的标点符号,都是"普通字符".表达式中的普通字符,在匹配一个字符串的时候,匹配与之相同的 ...

  10. python之路:进阶 二

        c = collections.Counter(  Counter({ b = collections.Counter(  b.update(c)   Counter({ Counter({  ...