国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

poj 3096 Surprising Strings

2019-11-11 01:58:18
字體:
供稿:網(wǎng)友

題意:

看題目示例領(lǐng)會(huì)

Consider the string ZGBG. Its 0-pairs are ZG, GB, and BG. Since these three pairs are all different, ZGBG is 0-unique. Similarly, the 1-pairs of ZGBG are ZB and GG, and since these two pairs are different, ZGBG is 1-unique. Finally, the only 2-pair of ZGBG is ZG, so ZGBG is 2-unique. Thus ZGBG is surPRising.

解題思路:

用map存每個(gè)pair,判斷是否存在即可。

代碼:

#include <iostream>#include <cstdio>#include <map>#include <string>#include <cstring>using namespace std;int main(){    string str;    while(cin>>str)    {        map<string, int>d[80];        if(str=="*")break;        int i, j;        int len=str.size();        string mpstr;        int ans=1;        for(i=1; i<=len-1; i++)        {            for(j=0; j+i<len; j++)            {                char e[11];                e[0]=str[j];                e[1]=str[j+i];                e[2]='/0';                mpstr=e;//                cout<<mpstr<<endl;                if(d[i].find(mpstr)!=d[i].end())ans=0;                else d[i][mpstr]=1;            }        }        if(ans)        {            cout<<str<<" is surprising."<<endl;        }        else cout<<str<<" is NOT surprising."<<endl;    }    return 0;}


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临桂县| 宁城县| 宁明县| 弋阳县| 樟树市| 衡水市| 廊坊市| 静安区| 洪雅县| 伊宁县| 柳林县| 岳西县| 桐庐县| 怀远县| 汤原县| 中江县| 扬州市| 栾川县| 馆陶县| 天镇县| 资源县| 土默特右旗| 涞水县| 青冈县| 阿合奇县| 天长市| 新乡市| 漾濞| 土默特右旗| 瑞金市| 赣州市| 永平县| 怀仁县| 六枝特区| 利辛县| 苏尼特右旗| 信阳市| 滦南县| 清水河县| 旬邑县| 四会市|