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. Summary: Lowest Common Ancestor in a Binary Tree & Shortest Path In a Binary Tree

    转自:Pavel's Blog Now let's say we want to find the LCA for nodes 4 and 9, we will need to traverse th ...

  2. zw版【转发·台湾nvp系列Delphi例程】HALCON Regiongrowing

    zw版[转发·台湾nvp系列Delphi例程]HALCON Regiongrowing procedure TForm1.Button1Click(Sender: TObject);var img : ...

  3. wonderware historian 10安装配置

    安装文件为: 关闭用户控制 配置dcom. 安装.net framework 3.5 安装sql server,打sp1补丁 安装Historain 停止ww服务 安装sp1包 重启机器,启动ww服务 ...

  4. pandas练习(四)--- 应用Apply函数

    探索学生对酒的消费情况 数据见github 步骤1 - 导入必要的库 import pandas as pd import numpy as np 步骤2 - 数据集 path4 = "./ ...

  5. Java(16-19)

    0. 正则表达式: str.matches()  //判断字符串是否匹配 str.split()  // 根据给定正则表达式的匹配规则.拆分此字符串,返回字符串数组. str.replaceAll() ...

  6. Request 对象 response 对象 常见属性

    请求和响应 Express 应用使用回调函数的参数: request 和 response 对象来处理请求和响应的数据. app.get('/', function (req, res) { // - ...

  7. 怎么归档老日志的shell脚本

    本脚本来自有学习阿铭的博文学习:工作中,需要用到日志切割logrotate,按照各自的需要切割.定义保留日志.提示:本文中的S全部都$符,不要问为什么,马云爸爸的社区就这样. #用途:日志切割归档.按 ...

  8. Python中模块(Module)和包(Package)的区别

    本文绝大部分内容转载至:廖雪峰官方网站 1. 模块(Module) 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函 ...

  9. python模块-json、pickle、shelve

    json模块 用于文件处理时其他数据类型与js字符串之间转换.在将其他数据类型转换为js字符串时(dump方法),首先将前者内部所有的单引号变为双引号,再整体加上引号(单或双)转换为js字符串:再使用 ...

  10. nginx location正则写法

    nginx location正则写法 一个示例: location = / { # 精确匹配 / ,主机名后面不能带任何字符串 [ configuration A ] } location / { # ...