| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 38834 | 23级徐泽厚 | 【S】T2 | C++ | 运行超时 | 68 | 2000 MS | 1744 KB | 1410 | 2025-11-06 15:37:25 |
#include <bits/stdc++.h> // #define int long long using namespace std; int T,type; string s; int n; signed main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>T>>type; while (T--){ cin>>s; n=s.size(); if (type==1){ if (s[n-1]==s[n-2]){ cout<<"1\n"; } else if (n-3>=0 && s[n-1]==s[n-3]){ cout<<"2\n"; } else{ cout<<"3\n"; } } s=' '+s; int ansm=0; for (int i=1;i<n;i++){ for (int j=i+1;j<=n;j++){ int nxt=0; while (j+nxt<=n){ if (s[j+nxt]!=s[i+nxt]){ break; } nxt++; } nxt--; int lans=n-(i+nxt); lans+=n-(j+nxt); ansm=max(ansm,lans); } } if (type==0){ cout<<ansm<<"\n"; } else{ cout<<ansm<<" "; if (s[n]==s[n-1]){ cout<<"1\n"; } else if (n-2>=1 and s[n]==s[n-2]){ cout<<"2\n"; } else{ cout<<"3\n"; } } } cout.flush(); return 0; }