hihoCoder #1039 : 字符消除
来源:互联网 发布:英雄联盟怎么玩 知乎 编辑:程序博客网 时间:2024/05/22 17:00
题目链接:
https://hihocoder.com/problemset/problem/1039
题解:
暴力模拟直接上。
(自己中文的题意都理解成错了,心累啊。)
代码:
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define met(a,b) memset(a,b,sizeof(a))#define inf 0x3f3f3f3fconst int maxn = 100+10;typedef long long ll;int visited[maxn];int main(){ int t; cin>>t; while(t--) { string s; cin>>s; int MAX=-inf; int ans=0; for(int i=0;i<s.size();i++) { for(char j='A';j<='C';j++) { string s1,s2; s1=s; s2=""; s2+=j; s1.insert(i, s2); string ss=s1; ans=0; while(1) { s1=ss; ss="";// cout<<s1<<endl; int flag=0; for(int k=0;k<s1.size()-1;k++) { if(s1[k]==s1[k+1]) { flag=1; break; } } if(!flag||s1.size()==0) break; met(visited,0); for(int k=0;k<s1.size();k++) { if(k==0) { if(s1[k]!=s1[k+1]) visited[k]=1; } else if(k==s1.size()-1) { if(s1[k]!=s1[k-1]) visited[k]=1; } else { if(s1[k]!=s1[k-1]&&s1[k]!=s1[k+1]) visited[k]=1; } }// for(int k=0;k<s1.size();k++)// {// cout<<visited[k]<<" ";// }// cout<<endl; ll len=s1.size(); int cnt=0; for(int k=0;k<len;k++) {// cout<<visited[k]<<" "; if(visited[k]) { cnt++; ss+=s1[k]; } }// cout<<cnt<<endl; ans+=len-cnt; } MAX=max(MAX,ans);// cout<<MAX<<endl; } } cout<<MAX<<endl; }}
阅读全文
0 0
- hihoCoder:#1039 字符消除
- HihoCoder#1039:字符消除
- hihocoder #1039 : 字符消除
- hihoCoder 1039 字符消除
- hihoCoder 1039 字符消除
- #hihocoder #1039 字符消除
- hihocoder#1039 : 字符消除
- hihocoder #1039 : 字符消除
- hihocoder 1039 字符消除
- Hihocoder 1039 : 字符消除
- hihoCoder #1039 : 字符消除
- hihoCoder 1039 字符消除
- hihoCoder #1039 : 字符消除
- hihocoder #1039 : 字符消除
- hihoCoder--1039 字符消除
- [HihoCoder]#1039 : 字符消除
- hihocoder #1039 : 字符消除
- 【hihoCoder】#1039 : 字符消除
- 结合人类视觉注意力
- 欢迎使用CSDN-markdown编辑器
- ZOOM论文
- Grep命令的详细使用方法
- Intellij Idea安装主题包
- hihoCoder #1039 : 字符消除
- 《OpenGL v1.1》——(1)接入Win32窗口,并描绘基本图元
- 推荐算法——冷启动问题
- 2017.07.20-0722 没写日记
- Selenium的使用方法
- Matlab svm工具箱配置及‘qp’报错的解决方法
- HDOJ 5154 Harry and Magical Computer (拓扑排序)
- Java入门(第一篇博客)
- ajax参数介绍