#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t—) { string s; cin>>s; int ans=1e9; int l=0; unordered_map<char,int> t; for(int r=0;r<s.size();r++) { t[s[r]]++; while(t[‘1’]>=1&&t[‘2’]>=1&&t[‘3’]>=1) { ans=min(ans,r-l+1); t[s[l]]—; l++; } } cout<<(ans==1e9?0:ans)<<endl; } return 0; }
www
文章信息与版本
文章信息
- 收录
- 2025年12月12日
- 更新
- 2025年12月12日
- 篇幅
- 约 1 分钟