| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 38839 | 23级徐泽厚 | 【S】T2 | C++ | 解答错误 | 92 | 239 MS | 2600 KB | 1997 | 2025-11-06 16:08:02 |
#include <bits/stdc++.h> // #define int long long using namespace std; int T,type; string s; int n; void mn(){ 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"; } return ; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>T>>type; while (T--){ cin>>s; n=s.size(); s=' '+s; if (type==1){ mn(); continue; } 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{stdout // cout<<"3\n"; // } // } int sam=0; for (int i=2;i<=n;i++){ if (s[i]!=s[i-1]){ sam=1; break; } } if (sam==0){ cout<<n-1<<" "; mn(); continue; } // int lans=0; for (int i=2;i<=n;i++){ if (s[i]!=s[1]){ ansm=(n-i+1)+n; break; } } cout<<ansm<<" "; if (type!=1) mn(); } cout.flush(); return 0; }