提交时间:2022-07-13 11:47:40
运行 ID: 51503
#include <iostream> #include <fstream> #include <string> using namespace std; int n,k,type,ans; string s,ss; int main(){ freopen ( "seq.in","r",stdin ); cin >> n >> k >> type >> s; //find_longest_sub_string(s,ss,ans); for ( int i=0; i<s.size(); i++ ){ int j=0; while ( 1 ){ if ( (j>0&&s[i]==ss[j-1])||(j>i) ){ cout << "\n j=" << j << "\n s[i]=" << s[i] << " ss[j-1]=" << ss[j-1]; break; } ss[j]=s[i]; j++; ans++; } } //print_answer(); freopen ( "seq.out","w",stdin ); cout << endl << ans; if ( type==1 ){ cout << endl << ss; } else if ( type==2 ){ //cout << ss; } return 0; }