zoukankan      html  css  js  c++  java
  • CodeForces

    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[32];
    13     long long Loc = 20000;
    14     bool fail = false;
    15     while (n--)
    16     {
    17         memset(dir, 0, sizeof(dir));
    18         scanf("%lld", &len);
    19         scanf("%s", dir);
    20         getchar();
    21         if (strcmp("South", dir) && Loc == 20000)
    22         {
    23             fail = true;
    24             break;
    25         }
    26         if (strcmp("North", dir) && Loc == 0)
    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 > 20000 || Loc < 0)
    40         {
    41             fail = true;
    42             break;
    43         }
    44     }
    45     if (fail)
    46     {
    47         printf("NO
    ");
    48     }
    49     else
    50     {
    51         if (Loc == 20000) printf("YES
    ");
    52         else printf("NO
    ");
    53     }
    54     return 0;
    55 }
  • 相关阅读:
    HDUOJ---1863畅通工程
    HDUOJ---1879 继续畅通工程
    HDUOJ---1102Constructing Roads
    HDUOJ---1102Constructing Roads
    hdu--DFS
    poj1611---The Suspects
    nyoj-----幸运三角形
    HDUOJ --2523
    HDUOJ---1195Open the Lock
    HDUOJ----2952Counting Sheep
  • 原文地址:https://www.cnblogs.com/oscar-cnblogs/p/6390241.html
Copyright © 2011-2022 走看看