poj 3096 Surprising Strings

来源:互联网 发布:中国网络接口 编辑:程序博客网 时间:2024/05/29 19:09

很简单的题了吧……

/* * Author: stormdpzh * POJ: 3096 Surprising Strings * Time: 2012/5/7 21:28:34 */#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cmath>#include <vector>#include <queue>#include <stack>#include <set>#include <algorithm>#include <functional>#define sz(v) ((int)(v).size())#define rep(i, n) for(int i = 0; i < n; i++)#define repf(i, a, b) for(int i = a; i <= b; i++)#define out(n) printf("%d\n", n)#define wh(n) while(scanf("%d", &n) != EOF)#define whz(n) while(scanf("%d", &n) != EOF && n != 0)#define lint long longusing namespace std;set<string> st;string str;int main(){    //freopen("data.in", "r", stdin);    while(cin >> str && str != "*") {        bool flag = true;        int len = str.size();        for(int i = 0; i < len - 1; i++) {            st.clear();            for(int j = 0; j < len - i - 1; j++) {                string tmp = "";                tmp += str[j];                tmp += str[j + 1 + i];                if(st.find(tmp) == st.end()) {                    st.insert(tmp);                }                else {                    flag = false;                    break;                }            }            if(!flag) break;        }        if(flag)            cout << str << " is surprising." << endl;        else            cout << str << " is NOT surprising." << endl;    }    return 0;}


原创粉丝点击