codeforce_NewYearandNorthPole-古蔺大橙子建站
RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
codeforce_NewYearandNorthPole

#include
#include

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:空间域名、雅安服务器托管、营销软件、网站建设、寻甸网站维护、网站推广。

int main(){
 int n;  //步骤数

 char str[10];
 int south=20000,north=0;
 int flag=2;  //做标记,在北极用2表示,在南极用1表示,在其他地方用0表示 
 int steps;  //步数
 
 scanf("%d",&n);
    for(int i=0;i   scanf("%d %s",&steps,str);
   //判定执行指令之前是否可继续前进
   if( flag==1 ) {
    if(strcmp(str,"North")){
     printf("NO\n");
     return 0;
      }
   }else if(flag==2){
    if(strcmp(str,"South")){
     printf("No\n");
     return 0;
    }
   }
   //判定执行过程中是否可继续前进
   if(!strcmp(str,"North")){
    if(steps>north){
     printf("NO\n");
     return 0;
    }
   }else if(!strcmp(str,"South")){
    if(steps>south){
     printf("NO\n");
     return 0;
    }
   }
   //继续前进
   if(!strcmp(str,"North")){
    north-=steps;
    south+=steps;
   } else if(!strcmp(str,"South")){
    north+=steps;
    south-=steps;
   }
  //在南极时
  if(north==20000){ 
   flag=1;
  }
  //在北极时
  else if(south==20000){
         flag=2;
  }else{
   flag=0;
  }
    }
    if(north==0){
     printf("YES\n");
 }else{
  printf("NO\n");
 }
 return 0;
}


本文名称:codeforce_NewYearandNorthPole
文章来源:http://scgulin.cn/article/pedcsd.html