Submission #18430

#TimeUsernameProblemLanguageResultExecution timeMemory
18430mindol구간 성분 (KOI15_interval)C++14
100 / 100
531 ms1856 KiB
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> using namespace std; string A,B; set<vector<int>> S; int main() { cin>>A>>B; for(int i=min(A.size(),B.size());i>=1;i--) { S.clear(); vector<int> p(26,0); for(int j=0;j<i;j++) p[A[j]-'a']++; S.insert(p); for(int j=i;j<A.size();j++) { p[A[j-i]-'a']--; p[A[j]-'a']++; S.insert(p); } vector<int> q(26,0); for(int j=0;j<i;j++) q[B[j]-'a']++; if(S.find(q)!=S.end()){ cout<<i; return 0; } for(int j=i;j<B.size();j++) { q[B[j-i]-'a']--; q[B[j]-'a']++; if(S.find(q)!=S.end()){ cout<<i; return 0; } } } 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...