Codeforces 298A Snow Footprints 题解
题意
雪地里有一条路,可以向左走、向右走,每走一步会在这一步的起点留下一个朝向走的方向的脚印,新脚印会覆盖旧脚印,现给出脚印的情况,判断起点和终点
思路
如果只有一个方向的脚印,那就是从脚印的一头走到另一头,如果两个方向都有,那一定是若干个R以后若干个L,那么就以第一个R为起点,最后一个R为重点就可以了
代码
#include <cstdio>
#include <iostream>
using namespace std;
char ss[1001];
int main()
{int n,s,t,f1,f2;cin>>n;cin>>ss;f1=0;f2=0;for(int i=0;i<n;i++)if(ss[i]=='L')f1=1;else if(ss[i]=='R')f2=1;if(f1==0){for(int i=0;i<n;i++)if(ss[i]=='R'){s=i+1;break;}for(int i=n-1;i>=0;i--)if(ss[i]=='R'){t=i+2;break;}}else if(f2==0){for(int i=n-1;i>=0;i--)if(ss[i]=='L'){s=i+1;break;}for(int i=0;i<n;i++)if(ss[i]=='L'){t=i;break;}}else{for(int i=0;i<n;i++)if(ss[i]!='.'){s=i+1;break;}for(int i=s-1;i<n-1;i++)if(ss[i]!=ss[i+1]){t=i+1;break;}}cout<<s<<" "<<t<<endl;return 0;
}
Codeforces 298A Snow Footprints 题解相关推荐
- 298A Snow Footprints
http://codeforces.com/problemset/problem/298/A 归纳题,若是存在R或者L,则必定左边为R,右边卫L,开始地点随意定在存在L或者R的位置,结束地点定在L和R ...
- CodeForces 298A Snow Footprints
1.http://codeforces.com/problemset/problem/298/A 2.题目大意:给定一个小球,可以往左往右移动,如果小球从第i个位置移到第i+1个位置,那么第i个位置将 ...
- Codeforces Round #180 (Div. 2) A. Snow Footprints 贪心
A. Snow Footprints 题目连接: http://www.codeforces.com/contest/298/problem/A Description There is a stra ...
- 文章标题 CoderForces 298A: Snow Footprints(水)
Snow Footprints Description There is a straight snowy road, divided into n blocks. The blocks are nu ...
- codeforces div2 Not Assigning 题解
codeforces div2 Not Assigning 题解 原题链接 /* 题意:构造一棵素数树.素数树定义如下: 这颗树中任意一条边 or 任意两条边 权重之和为素数,每条边的权重自己分配. ...
- Snow Footprints CodeForces - 298A
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left ...
- Codeforces Round#713 A-E题解
Codeforces Round 713 经典暴力模拟掉分场 本场链接: https://codeforces.com/contest/1512 个人博客の极致色彩简洁版题解: http://www. ...
- 【codeforces】【比赛题解】#940 CF Round #466 (Div. 2)
人生的大起大落莫过如此,下一场我一定要回紫. [A]Points on the line 题意: 一个直线上有\(n\)个点,要求去掉最少的点,使得最远两点距离不超过\(d\). 题解: 暴力两重fo ...
- Codeforces Good Bye 2016 题解
好久没有fst题了...比赛先A了前4题然后发现room里有人已经X完题了没办法只能去打E题,结果差一点点打完...然后C题fst掉了结果就掉rating 了...下面放题解 A. New Year ...
最新文章
- 基于LSTM的股票价格预测(完整金融类代码)
- JJWT签发与验证token
- Python网页抓取、模拟登录
- 使用Tomcat部署应用
- 分布式ID生成的9种方法,特好用!
- IndexedDB 简单封装
- 世界上最漂亮的写作工具Typora(创作者必备软件)
- 在线的SA 绘图工具-Mockups
- Asp.Net细节性问题精萃
- PDF图纸怎么导入CAD中?尝试这样操作一下
- 千树万树梨花开:二叉树的实现以及存储结构
- Win8.1的IE缓存文件夹哪里去了?细说系统安装分区里那些带箭头的文件夹
- java 两张图片合并_java实现把两张图片合并(Graphics2D)
- 微分几何与广义相对论教程
- 在IPCam上搭建WEB服务并通过CGI交互的相关问题
- 能帮我看看那里错了吗
- 所有过往、皆为序章:我的2021
- PR CC 2018添加素材时出现绿色/紫色横线
- python中国大学慕课平台_计算机程序设计-Python,中国大学MOOC(慕课)答案公众号搜题...
- 计算机如何打开无线网络适配器,电脑WIFI网络适配器卡怎么启用