#include<iostream> #include<stdio.h> #include<vector> #include <algorithm> #include <functional> #include<string> #include<fstream> #include <sstream> #include <assert.h> using namespace std; class Solution { public: int lengthOfLongestSubstring(string s) { if (s.length() == 0)//如果字符串的长度为0,则返回空即为0 return 0; int size, i = 0, j, k, max = 0;//初始化一些变量 size = s.length();//获得字符串的长度 for (j = 0; j < size; j++)//遍历字符串 { for (k = i; k < j;k++)//下个字符串是否和当前字符相同,若相同跳出当前遍历 if (s[k] == s[j]){ i = k + 1; break; } if (j - i + 1>max)//求取不相同的字符串的大小 max = j - i + 1; } return max; } }; string stringToString(string input) { assert(input.length() >= 2); string result; for (int i = 1; i < input.length() - 1; i++) { char currentChar = input[i]; if (input[i] == '\') { char nextChar = input[i + 1]; switch (nextChar) { case '"': result.push_back('"'); break; case '/': result.push_back('/'); break; case '\': result.push_back('\'); break; case 'b': result.push_back(''); break; case 'f': result.push_back('f'); break; case 'r': result.push_back(' '); break; case 'n': result.push_back(' '); break; case 't': result.push_back(' '); break; default: break; } i++; } else { result.push_back(currentChar); } } return result; } int main() { string line; while (getline(cin, line)) { string s = stringToString(line); int ret = Solution().lengthOfLongestSubstring(s); string out = to_string(ret); cout << out << endl; } return 0; }