题目链接:
[POJ 3096]Surprising Strings[map]
题意分析:
相距0、1、2......s.length() - 1的两个字符所在的串集合中是否有重复的字符串,有则not,无则is。
解题思路:
枚举,map映射即可。
个人感受:
79长度,随意搞啊。
具体代码如下:
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#define ll long long
#define pr(x) cout << #x << " = " << (x) << '\n';
using namespace std;
map<string, bool> mp;
int main()
{
string s;
while (cin >> s && s != "*") {
bool is = 1;
for (int i = 1; i < s.length() && is; ++i) {
mp.clear();
string t;
for (int j = 0; j + i < s.length(); ++j) {
t.push_back(s[j]);
t.push_back(s[j + i]);
if (mp[t]) {
is = 0;
break;
}
mp[t] = 1;
t.clear();
}
}
cout << s << " is ";
if (!is) cout << "NOT ";
cout << "surprising.\n";
}
return 0;
}