http://codeforces.com/problemset/problem/750/B

模拟题

审题 在南极点 只能向北走(不能向 南 东 西) 所以也就不存在走过南极点的情况 北极点同样

然后去模拟那个走的过程 不符合条件就fail即可

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4. using namespace std;
  5.  
  6. int n;
  7. int main()
  8. {
  9. freopen("in.txt" ,"r", stdin);
  10. scanf("%d", &n);
  11. long long len;
  12. char dir[];
  13. long long Loc = ;
  14. bool fail = false;
  15. while (n--)
  16. {
  17. memset(dir, , sizeof(dir));
  18. scanf("%lld", &len);
  19. scanf("%s", dir);
  20. getchar();
  21. if (strcmp("South", dir) && Loc == )
  22. {
  23. fail = true;
  24. break;
  25. }
  26. if (strcmp("North", dir) && Loc == )
  27. {
  28. fail = true;
  29. break;
  30. }
  31. if (!strcmp(dir, "North"))
  32. {
  33. Loc += len;
  34. }
  35. if (!strcmp(dir, "South"))
  36. {
  37. Loc -= len;
  38. }
  39. if (Loc > || Loc < )
  40. {
  41. fail = true;
  42. break;
  43. }
  44. }
  45. if (fail)
  46. {
  47. printf("NO\n");
  48. }
  49. else
  50. {
  51. if (Loc == ) printf("YES\n");
  52. else printf("NO\n");
  53. }
  54. return ;
  55. }

CodeForces - 750B New Year and North Pole的更多相关文章

  1. 【codeforces 750B】New Year and North Pole

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. CodeFroces--Good Bye 2016-B--New Year and North Pole(水题-模拟)

    B. New Year and North Pole time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  3. Good Bye 2016

    A - New Year and Hurry (water) #include <bits/stdc++.h> using namespace std; int main() { ]; ; ...

  4. Inverted sentences

    And ever has it been that love knows not its own depth until the hour of separation.  除非临到了别离的时候,爱永远 ...

  5. ural 1341. Device

    1341. Device Time limit: 1.0 secondMemory limit: 64 MB Major (M): You claimed that your device would ...

  6. News common vocabulary

    英语新闻常用词汇与短语 经济篇 accumulated deficit 累计赤字 active trade balance 贸易顺差 adverse trade balance 贸易逆差 aid 援助 ...

  7. 越狱Season 1- Episode 16

    Season 1, Episode 16 -Burrows:Don't be. It's not your fault. 不要,不是你的错 -Fernando: Know what I like? 知 ...

  8. vacabulary1

    The hard hat is rigid,so nothing will hurt my head. glue 胶水vegetarian 素食者: 素食主义者:素食的 North Korea 朝鲜S ...

  9. esriSRProjCS3Type Constants

    ArcGIS Developer Help  (Geometry)   esriSRProjCS3Type Constants See Also esriSRProjCSType Constants ...

随机推荐

  1. 学JAVA第二十四天,Set集合与StringBuilder

    下面的内容需要慢慢看,因为,我的语言表达能力不是很好 首先说Set把,Set集合是一个无序且不允许重复的集合,而且查找效率也是快的可怕的. 但是,有些时候,我们必须要用储存多个相同的值时,Set也是可 ...

  2. intellij idea 调试 lua程序, 突然崩溃或者xmx不够的情况

    将内存各方面的数值都改大一点.都什么时代了,默认数值还这么低... -server-Xms256m-Xmx1024m-XX:ReservedCodeCacheSize=240m-XX:+UseConc ...

  3. 【学习笔记】深入理解js原型和闭包(13)——【作用域】和【上下文环境】

    上文简单介绍了作用域,本文把作用域和上下文环境结合起来说一下,会理解的更深一些. 如上图,我们在上文中已经介绍了,除了全局作用域之外,每个函数都会创建自己的作用域,作用域在函数定义时就已经确定了.而不 ...

  4. oracle适配器连接不上解决方案

    Oracle适配器连接不上解决方案 作者:Vashon oracle 的Developer连接不上报错:listener does not currently know of SID given in ...

  5. 原生JS--各种兼容性写法总结

    <script> var oEvent = evt || event; ========================================================== ...

  6. JVM 内存区域方面的面试题

    https://mp.weixin.qq.com/s/TpCElutqVSt7PAzjrGz12w 写在前面(常见面试题) 基本问题 •介绍下 Java 内存区域(运行时数据区)•Java 对象的创建 ...

  7. Format a Hard Drive in Csharp

    Article Author(s): Audric Thevenet All Rights Reserved. Here's how to format hard drives, floppies, ...

  8. C ++ _基础之共用体

    由以下代码来进一步学习共用体 #include <stdio.h> #include<iostream> void main() { union un { int a; cha ...

  9. manjaro利用docker使用MySQL

    使用docker安装MySQL并使用 安装docker: sudo yaourt -S docker 使用docker安装mysql: systemctl start docker # 启动docke ...

  10. avalon转成Vue

    需求: 旧项目中有部分页面是用avalon写的,avalon存在页面刷新,会出现重复行的问题,数组渲染出现重复行bug, 需要转成vue 总结 记录了一下大概需要改的地方 1. avalon中的ms- ...