Open utterances-bot opened 1 year ago
Mình làm rất chi tiết và dễ hiểu. Có giải thích chi tiết bên trong code.
#include
admin cho xin cai test vs lam mai chi co 7/10 :))))))))
test 3,4,5
code full test bool kt(){ for (int i1=0;i1<=l-g;i1++){ string s1=st.substr(i1,g); int j=0; while (s1.find(s[j])<g && j<26) j++; if (j==26) return true; } return false; } int main(){ cin>>st;l=st.size(); if (l<26) {cout<<-1;exit(0);} i=0; while (st.find(s[i])<l && i<26) i++; if (i==26){ t=26;p=l; while (t<=p){ g=(t+p)/2; if (kt()) {p=g-1;res=g;} else t=g+1; } cout<<res; } else cout<<-1; return 0; }
using namespace std; string st,s="QWERTYUIOPASDFGHJKLZXCVBNM"; int i,l,res,t,p,g; bool kt(){ for (int i1=0;i1<=l-g;i1++){ string s1=st.substr(i1,g); int j=0; while (s1.find(s[j])<g && j<26) j++; if (j==26) return true; } return false; } int main(){ cin>>st;l=st.size(); if (l<26) {cout<<-1;exit(0);} i=0; while (st.find(s[i])<l && i<26) i++; if (i==26){ t=26;p=l; while (t<=p){ g=(t+p)/2; if (kt()) {p=g-1;res=g;} else t=g+1; } cout<<res; } else cout<<-1; return 0; }
Chi tiết bài tập - Luyện Code Online
https://oj.luyencode.net/problem/FULLSTR