记录编号 |
236673 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
[国家集训队2011]悄悄话 |
最终得分 |
100 |
用户昵称 |
mikumikumi |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.083 s |
提交时间 |
2016-03-15 07:25:35 |
内存使用 |
0.33 MiB |
显示代码纯文本
//超TM神奇的算法
//大题思路是尝试每一种解码方式,然后对每一种解码方式进行估价
#include<cstdio>
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
const int SIZED=26,SIZEL=20010;
string text[30];
string dic[SIZED]={"you","they","he","she","and","a","an","the","are","is","it",
"that","me","i","on","of","in","but","how","what","who","to","no","do","we","this"};//词典,用于小单词匹配
int val[30];
map<string,int> mp;
void prepare()
{
for(int i=0;i<SIZED;i++) mp[dic[i]]=7;
char hle[]={'a','e','s','t','i','r'};//高频字符
char lle[]={'v','z','w','q','y','x'};
for(int i=0;i<6;i++)
{
//cout<<i<<" "<<hle[i]-'a'<<" "<<lle[i]-'a'<<" "<<strlen(hle)<<endl;
val[hle[i]-'a']++;val[lle[i]-'a']--;
}
}
bool type[SIZEL];
void mark()
{
memset(type,0,sizeof(type));
for(int i=0;i<text[0].size();i++)
{
if('A'<=text[0][i]&&text[0][i]<='Z')
{
text[0][i]='a'+text[0][i]-'A';
type[i]=1;
}
}
}
bool pan(char a)
{
if('a'<=a&&a<='z') return 1;
return 0;
}
void change(int x)
{
text[x]="\0";
for(int i=0;i<text[0].size();i++)
{
text[x]+=text[0][i];
if(pan(text[x][i]))
{
text[x][i]='a'+(text[x][i]-'a'+x)%26;
//if(text[x][i]>'z') text[x][i]-=26;
}
}
}
void print(string a)
{
for(int i=0;i<a.size();i++)
{
if(type[i])
{
a[i]=a[i]-'a'+'A';
}
}
cout<<a<<endl;
}
int getsum(string b)
{
int re=0;
re+=mp[b];
if(b[0]=='d'&&b[1]=='i'&&b[2]=='s') re+=3;
if(b[0]=='i'&&b[1]=='m') re+=3;
return re;
}
int calc(int x)
{
int re=0;
int n=text[x].size();
for(int i=0;i<n;i++)
{
if(pan(text[x][i])) re+=val[text[x][i]-'a'];
if(text[x][i]=='i'&&type[i]==1)
{
re+=4;
if(i+1<n&&text[x][i+1]=='\'') re+=4;
}
if(text[x][i]=='\'')
{
if(i+1<n&&(text[x][i+1]=='s'||text[x][i+1]=='m')) re+=4;
}
}
int i=0,j=0;
while(i<n)
{
while(i<n&&!pan(text[x][i])) i++;
j=i;
string b;
while(j<n&&pan(text[x][j])) b+=text[x][j++];
i=j;
re+=getsum(b);
//cout<<b<<endl;
}
return re;
}
void work()
{
getline(cin,text[0]);
mark();
for(int i=1;i<26;i++) change(i);
int ans=-100,id=-1;
for(int i=0;i<26;i++)
{
int tem=calc(i);
if(tem>ans)
{
ans=tem;
id=i;
}
}
print(text[id]);
}
int main()
{
freopen("msg.in","r",stdin);
freopen("msg.out","w",stdout);
prepare();
for(int i=1;i<=10;i++) work();
return 0;
}