第二次比赛,我感受到了我心态的问题,还有思维的缺陷把。 容易钻进死胡同。 这道题题意很简单,就是要去找符合条件的字符串。

/*If I get TLE , it is good.If I get AC,it's NICE !*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <cmath>
#include <queue>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const int MAXN=1e7+10;
const ll mod=1e9+7;
using namespace std;
typedef long long ll;
map <string,int> temp;
char str[MAXN];
int is(char x)
{if(x>='0'&&x<='9')return 1;else return 0;
}
int main(void)
{temp.clear();scanf("%s",str+1);int len=strlen(str+1);for(int i=1; i<=len-9; i++){if(  is(str[i]) &&is(str[i+1]) &&str[i+2]=='-' &&is(str[i+3]) && is(str[i+4])  && str[i+5]=='-' && is(str[i+6]) && is(str[i+7] )&&  is(str[i+8]) &&  is(str[i+9])  ){int nian=(str[i+9]-'0')*1+(str[i+8]-'0')*10+(str[i+7]-'0')*100+(str[i+6]-'0')*1000;int yue=(str[i+3]-'0')*10+str[i+4]-'0';int ri=(str[i]-'0')*10+str[i+1]-'0';if(yue==0 || ri==0) continue;if(yue==4 ||yue==6 ||yue==9 ||yue==11  ){if(ri==31)  continue;}if(nian<2013 || nian>2015)  continue;if(yue>12 || yue <1)  continue;if(yue==2){if(ri>=29 || ri ==0)continue;}string s;//s.resize(15);//s.clear();int k=i;for(int j=0;j<=9;j++){//s[j]=str[k++];s += str[k++];//printf("??? %d\n",s.size());}//cout << s <<endl;//cout <<temp[s] << endl;++temp[s];//cout <<temp[s] << endl;}}int maxx=-1;for(map<string,int>::iterator it= temp.begin();it!=temp.end();it++){if(maxx < it->second) maxx = it->second ;}for(map<string,int>::iterator it= temp.begin();it!=temp.end();it++){if(maxx == it->second) {(cout << it->first<<endl) ; return 0;}}
}

要注意的地方:
1.对于年份,注意闰年和平年对2月造成的影响;
2.对于月份,如果大于12,或者小于1,continue;
3.对于日,分类在闰年和平年的情况下,如果是闰年,2月如果大于30 || 小于1 continue; 其他月份分30,和31天;平年同理

还有对map容器遍历的过程,今天还是和学长请教了,实在不想看博客,静不下心来的表现.(对MAP的遍历还要多敲几遍,熟悉套路)

for(map<string,int>::iterator it= temp.begin();it!=temp.end();it++){if(maxx < it->second) maxx = it->second ;}for(map<string,int>::iterator it= temp.begin();it!=temp.end();it++){if(maxx == it->second) {(cout << it->first<<endl) ; return 0;}}

这场比赛下来,我学到了什么
1.对于思维题,一定要活跃一点。
2.如果做不出来,可以先放一放,看下面的题,不要想着前面的题又做下面的题,不然一题都做不出来。

// 你TM就是个彩笔,大彩笔,还不努力

B - Ancient Prophesy CodeForces - 260B相关推荐

  1. CodeForces - 260B Ancient Prophesy

    CodeForces - 260B Ancient Prophesy A recently found Ancient Prophesy is believed to contain the exac ...

  2. Codeforces 260B - Ancient Prophesy

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

  3. 【CodeForces - 260B 】Ancient Prophesy (暴力匹配,BF算法,日期字符串)

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

  4. 【CodeForces 611D】Ancient Prophesy

    智障模拟.. 我也是智障.. 下面傻逼代码没有过.. #include<bits/stdc++.h> using namespace std; #define maxn 100100 ch ...

  5. B. Ancient Prophesy(模拟)

    题目链接---- 题目大意是给你一个字符串,找到出现次数最多的日期格式.dd-mm-yyyy 而且  yyyy是在2013 - 2015,并且dd-mm-yyyy满足日期正确性. 思路:就是模拟,但是 ...

  6. CodeForces - 260 - BAncient Prophesy(暴力)

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

  7. Codeforces Round #647 (Div. 2) - Thanks, Algo Muse!(AB)

    Johnny and Ancient Computer CodeForces - 1362A 思路:因为除或者乘的都是2的幂次,所以看看二者的商是不是2的幂次就可以了.如果是的话,就3,2,1依次就行 ...

  8. python程序段的基本结构_python3 第三章 - 程序的基本结构

    1.编码 默认情况下,Python 3 源码文件以 UTF-8 编码,所有字符串都是 unicode 字符串. 当然你也可以为源码文件指定不同的编码: # -*- coding: cp-1252 -* ...

  9. 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 ...

最新文章

  1. 显示DataGrid序号的一个适用的方法
  2. golang 遍历文件夹和文件
  3. Linux vi/vim使用方法 总结
  4. Get Form type using javascript in CRM 2011
  5. 【git】.gitignore文件
  6. python字符串可以保存在变量中吗_在python中可以从字符串变量实例化类吗?
  7. aspose 生成word 简单的文档操作
  8. springJdbc in 查询,Spring namedParameterJdbcTemplate in查询
  9. 并发框架Disruptor
  10. C 标准库 limits.h
  11. pytorch梯度的计算过程
  12. Acwing第 34 场周赛
  13. java映射的概念_Java之路:映射(Map)
  14. 小白学习HTML(一)——html基本格式
  15. 因为相信所以看见,既然看见注定坚信《12》
  16. 2017最新qq第三方登陆教程
  17. guess在Java中用法_guess的用法
  18. Java 的核心目的和并发编程
  19. OpenCV对矩阵进行padding操作
  20. CF 783 F. Vlad and Unfinished Business

热门文章

  1. 正版软件|摹客RP 产品原型设计工具
  2. JAVA毕业设计汉语言类网上考试系统计算机源码+lw文档+系统+调试部署+数据库
  3. 《Confident Learning: Estimating Uncertainty in Dataset Labels》论文讲解
  4. hp服务器330g6怎么安装系统,HP ProLiant ML330 G6配置和特点解析
  5. getenv(php7.0以上版本不不能使用的问题)
  6. export getenv动态获取导出变量
  7. 我的手机我做主 DIY个人手机应用平台
  8. 如何选择适合你的兴趣爱好(四十三),国际象棋
  9. 移动互联网时代,App地推是移动APP不可或缺的一部分
  10. Android踩坑小记:在onResume中申请权限