POJ_1056_IMMEDIATE DECODABILITY

#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; int main() { freopen("test.txt", "r", stdin); int n; vector<string> v; string s; int t = 1; while (cin>>s) { if (s[0] == '9') continue; v.push_back(s); while (cin>>s && s[0] != '9') v.push_back(s); sort(v.begin(), v.end()); bool flag = false; for (int i = 1; i < v.size(); i++) { if (v[i].substr(0, v[i-1].size()) == v[i-1]) { flag = true; break; } } if (!flag) cout<<"Set "<<t++<<" is immediately decodable"<<endl; else cout<<"Set "<<t++<<" is not immediately decodable"<<endl; v.clear(); } return 0; }

你可能感兴趣的:(include)