/* Alphabet SER 2016 by Dennis Matveyev How: Standard LIS Complexity: O(n log n) */ #include #include #include #include using namespace std; int L(string s) { vector::iterator low; vector v; for each (char c in s) { low = lower_bound(v.begin(), v.end(), c); if (low == v.end()) v.push_back(c); else *low = c; } return v.size(); } int main() { //harcoded for testing string s = "abcdefghijklmnopqrstuvw"; cout << 26 - L(s) << endl; return 0; }