Submission #51640

#TimeUsernameProblemLanguageResultExecution timeMemory
51640okaybody10구간 성분 (KOI15_interval)C++98
61 / 100
1052 ms172020 KiB
#include <iostream> #include <vector> #include <set> using namespace std; typedef vector<int> vi; set<vi> gg; int main() { cin.tie(NULL); ios::sync_with_stdio(false); string s1,s2; cin>>s1>>s2; int l1=s1.size(),l2=s2.size(); for(int i=l1;i>0;i--) { vi alpha(26); int s=0,e=i-1; for(int j=s;j<=e;j++) alpha[s1[j]-'a']++; while(e<l1) { gg.insert(alpha); if(++e<l1) alpha[s1[e]-'a']++,alpha[s1[s++]-'a']--; } } for(int i=l2;i>0;i--) { vi alpha(26); int s=0,e=i-1; for(int j=s;j<=e;j++) alpha[s2[j]-'a']++; while(e<l2) { if(gg.find(alpha)!=gg.end()) { cout<<i; return 0;} if(++e<l2) alpha[s2[e]-'a']++,alpha[s2[s++]-'a']--; } } cout<<0; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...