Good Bye 2016 - B
题目链接:http://codeforces.com/contest/750/problem/B
题意:地球的子午线长度为40000,两极点的距离为20000.现在你从北极出发,按照题目输入方式来走。有规定在北极时只能往南方向走,同理在南极。最后走完后要回到北极。问输入的路线是否合法。
思路:按照题意模拟就好了。定义Point为离北极的距离,初始Point为0,因为起点在北极。
当这次行动为w/e时如果Point为0/20000(在极点)时路线不合法。
当这次行动为n时,如果Point为20000(在南极)时路线不合法。
当这次行动为s时,如果Point为0(在北极)时路线不合法。
另外假设这次行动为s,并且要走的距离超过从当前位置到达南极的距离时也是不合法(不能从另一端绕圈)。同理其他情况。
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<time.h>
#include<cmath>
using namespace std;
typedef long long int LL;
const int MAXN = + ;
const int MAXL = ;
struct Node{
int dis;
char dir[];
}ope[MAXN];
int main(){
//#ifdef kirito
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//#endif
// int start = clock();
int n;
while (scanf("%d", &n) != EOF){
for (int i = ; i < n; i++){
scanf("%d %s", &ope[i].dis, ope[i].dir);
}
int Point = ; bool flag = true;
for (int i = ; i < n&&flag; i++){
if (ope[i].dir[] == 'W' || ope[i].dir[] == 'E'){
if (Point == || Point == MAXL){
flag = false;
}
}
else if (ope[i].dir[] == 'N'){
if (Point == ){
flag = false;
}
else{
if (ope[i].dis > Point){
flag = false;
}
else{
Point -= ope[i].dis;
}
}
}
else{
if (Point == MAXL){
flag = false;
}
else{
if (ope[i].dis > (MAXL - Point)){
flag = false;
}
else{
Point += ope[i].dis;
}
}
}
//printf("%d\n", Point);
}
printf(flag == true && Point == ? "YES\n" : "NO\n");
}
//#ifdef LOCAL_TIME
// cout << "[Finished in " << clock() - start << " ms]" << endl;
//#endif
return ;
}
Good Bye 2016 - B的更多相关文章
- codeforces Good bye 2016 E 线段树维护dp区间合并
codeforces Good bye 2016 E 线段树维护dp区间合并 题目大意:给你一个字符串,范围为‘0’~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问 ...
- Good Bye 2016 A. New Year and Hurry【贪心/做题目每道题花费时间按步长为5等差增长,求剩余时间够做几道题】
A. New Year and Hurry time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Good Bye 2016 E. New Year and Old Subsequence
传送门 题意: 给出一个长度为\(n\)的串,现在有\(q\)个询问,每个询问是一个区间\([l,r]\),要回答在区间\([l,r]\)中,最少需要删多少个数,满足区间中包含\(2017\)的子序列 ...
- Good Bye 2016
A - New Year and Hurry (water) #include <bits/stdc++.h> using namespace std; int main() { ]; ; ...
- Good Bye 2016 - D
题目链接:http://codeforces.com/contest/750/problem/D 题意:新年烟花爆炸后会往两端45°差分裂.分裂完后变成2部分,之后这2部分继续按这种规则分裂.现在给你 ...
- Good Bye 2016 - C
题目链接:http://codeforces.com/contest/750/problem/C 题意:在CF中,每个人都有个Rank值. 当Rank>=1900时,为DIV1.Rank< ...
- Good Bye 2016 - A
题目链接:http://codeforces.com/contest/750/problem/A 题意:有n场比赛要打,第i场比赛需要花i*5分钟来完成,比赛从20:00开始.然后新年派对24:00开 ...
- Good Bye 2016 //智商再次下线,边界爆炸.....
A B很水就略了.. C.又是一次wannafly一样的判断区间的..... 边界设为2000000 正好GG...... fst的时候立马想到上次也是这么wa过的...... 所以下次遇到这种题 ...
- Codeforces Good Bye 2016 D 模拟搜索?
给出烟花的爆炸方式和爆炸次数 问最后有多少个格子会被炸到 如果dfs的话会超时... 利用模拟每一层来搜索..? 思想就是一开始有一个爆炸点向上 然后模拟完第一段 会产生一个爆炸点 朝两个方向 就用v ...
随机推荐
- Apache Torque入门学习
Introduction Apache Torque is an object-relational mapper for java. In other words, Torque lets you ...
- Toad各版本所包含的组件
Toad for Oracle Base Edition Toad for Oracle Knowledge Xpert for PL/SQL Knowledge Xpert for Oracle A ...
- linux创建新用户以及修改密码
1. 使用root账户创建新用户 useradd webuser 2. 修改新增的用户的密码 passwd webuser 这时候会提示你输入新的密码: 注意:不要用su webuser进入该账户修改 ...
- java基础知识(十一)java反射机制(下)
1.什么是反射机制? java反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法,对于任意一个对象都能够调用他的属性和方法,这种动态获取属性和方法的功能称为java的反射机制. ...
- ASP.NET运作流程
当我们在浏览器输入域名访问服务器资源时,会向服务器发送Http请求,并经由IIS处理后,交由ASP.NET托管程序处理,进入ASP.NET管道.在IIS内部如何处理我们不需要深入去了解,在ASP.NE ...
- 如何做出透明背景的flash动画
最近碰到了一个问题,做动画时怎么设置透明背景,字是白色的,网上搜了一下,发现可以这样做 在插入的flash代码中加入这一行代码就可以实现了 <param name="wmode&quo ...
- sublime一些快捷键
语法: 后代:> 缩写:nav>ul>li <nav> <ul> <li></li> </ul> </nav> ...
- DataTable导出到Excel
简单的导出到Excel中: 代码如下: using System; using System.Collections.Generic; using System.Data; using System. ...
- Microsoft ACE OLEDB 12.0 数据库连接字符串
Excel 97-2003 Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myOldExcelFile.xls;Extended ...
- sharepoint关键位置
GAC:C:\Windows\assembly,也就是部署的位置: ISAPI位置,SharePoint API:C:\Program Files\Common Files\microsoft sha ...