260B - Ancient Prophesy

思路:字符串处理,把符合条件的答案放进map里,用string类中的substr()函数会简单一些,map中的值可以边加边记录答案,可以省略迭代器访问部分。

代码:

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+;
map<string,int>mp;
string s;
int d[]={,,,,,,,,,,,};
bool isOK(string s)
{
if(s[]!='-'||s[]!='-')return false;
if(s[]=='-'||s[]=='-'||s[]=='-'||s[]=='-')return false;
int a=(s[]-'')*+s[]-'';
int b=(s[]-'')*+s[]-'';
if(b<=||b>)return false;
if(a<=||a>d[b-])return false;
return true;
}
int main()
{
cin>>s;
int cnt=;
string ans;
for(int i=;i<s.size()-;i++)
{
if(s[i]==''&&s[i+]==''&&s[i+]==''&&''<=s[i+]&&s[i+]<='')
{
string s1=s.substr(i-,);
if(isOK(s1))
{
string s2=s.substr(i-,);
mp[s2]++;
if(mp[s2]>cnt)
{
cnt=mp[s2];
ans=s2;
}
}
}
}
cout<<ans<<endl;
return ;
}

Codeforces 260B - Ancient Prophesy的更多相关文章

  1. [codeforces 260]B. Ancient Prophesy

    [codeforces 260]B. Ancient Prophesy 试题描述 A recently found Ancient Prophesy is believed to contain th ...

  2. CodeForces - 260B

    A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is ...

  3. Codeforces 1C Ancient Berland Circus

    传送门 题意 给出一正多边形三顶点的坐标,求此正多边形的面积最小值. 分析 为了叙述方便,定义正多边形的单位圆心角u为正多边形的某条边对其外接圆的圆心角(即外接圆的某条弦所对的圆心角). (1)多边形 ...

  4. Codeforces 1045E. Ancient civilizations 构造 计算几何 凸包

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF1045E.html 4K码量构造题,CF血腥残暴! 题解 首先,如果所有点颜色相同,那么直接连个菊花搞定. ...

  5. Codeforces Round #158 (Div. 2)

    A. Adding Digits 枚举. B. Ancient Prophesy 字符串处理. C. Balls and Boxes 枚举起始位置\(i\),显然\(a_i \le a_j, 1 \l ...

  6. kgcd ,fmod,fgcd

    参考:NENU CS ACM模板made by tiankonguse  2.13 GCD 快速gcd: 位操作没学,真心不懂二进制,还是得学啊 code: int kgcd(){ if(!a || ...

  7. CodeForces 164 B. Ancient Berland Hieroglyphs 单调队列

    B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co ...

  8. Codeforces Good Bye 2015 D. New Year and Ancient Prophecy 后缀数组 树状数组 dp

    D. New Year and Ancient Prophecy 题目连接: http://www.codeforces.com/contest/611/problem/C Description L ...

  9. Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何

    C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays a ...

随机推荐

  1. c#string为传值模式

    闲的无聊,记忆中好像是在c/c++语言中string为传址模式(函数修改参数时会影响原来的string参数值),比较好奇c#下对于string参数到底是传值还是传址有些疑问,便亲自测试. 1.结果aa ...

  2. lnmp之mysql5.5.17安装

    先执行命令yum install cmake mysql5.5采用的是cmake安装(更先进的configure) wget下载目录(到清华大学的镜像站下载) [root@localhost loca ...

  3. [備註] 安裝與整合 xUnit 測試框架@VS2012

    開發環境:Visual Studio 2012, Update 1 (必須). 說明:VS2012 已整合各測試框架的 Test Runner,包括 NUnit, xUnit 等.藉由標準的介面,可讓 ...

  4. Masonry 适配label多行

    设置属性后,然后根据文本自动多行显示,无需设置标签高度约束 1 属性preferredMaxLayoutWidth,如:label.preferredMaxLayoutWidth = (WidthSc ...

  5. idea 上搭建 Mybatis 逆向工程

    网盘地址:https://pan.baidu.com/s/1VAILpdgQbFk9t89eEv_nWQ 提取码:xdyc

  6. python的subprocess的简单使用和注意事项

    subprocess是python在2.4引入的模块, 主要用来替代下面几个模块和方法: os.systemos.spawn*os.popen*popen2.*commands.* 可以参考PEP32 ...

  7. 拉取远程仓库到本地错误The authenticity of host 'github.com (13.229.188.59)' can't be established.

    1.个人在github上面创建了仓库,通过本地的git拉取远程仓库到本地报错信息如下: 这是因为Git使用SSH连接,而SSH第一次连接需要验证GitHub服务器的Key.确认GitHub的Key的指 ...

  8. php ci 报错 Object not found! The requested URL was not found on this server. If you entered the URL manually please check

    Object not found! The requested URL was not found on this server. The link on the referring page see ...

  9. web前端----JavaScript的BOM

    一.引入 到目前为止,我们已经学过了JavaScript的一些简单的语法.但是这些简单的语法,并没有和浏览器有任何交互. 也就是我们还不能制作一些我们经常看到的网页的一些交互,我们需要继续学习BOM和 ...

  10. MySQL数据库----流程控制

    流程控制 1.条件语句 举例一 delimiter // CREATE PROCEDURE proc_if () BEGIN declare i int default 0; if i = 1 THE ...