# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48816 | leehosu01 | 구간 성분 (KOI15_interval) | C++17 | 1083 ms | 1592 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string A,B;
bool Sh(ll len)
{
map<int,int>im;
set<map<int,int> > inA;
int i;
for(i=0;i<len;i++)im[A[i]]++;
inA.insert(im);
for(i=len;i<A.size();i++)
{
im[A[i]]++;
if(--im[A[i-len]]==0)
im.erase(A[i-len]);
inA.insert(im);
}
im.clear();
for(i=0;i<len;i++)im[B[i]]++;
if(inA.find(im)!=inA.end())return 1;
for(i=len;i<B.size();i++)
{
im[B[i]]++;
if(--im[B[i-len]]==0)
im.erase(B[i-len]);
if(inA.find(im)!=inA.end())return 1;
}
return 0;
}
int main()
{
cin>>A>>B;
int l=1,m,lm=0,r=min((int)A.size(),(int)B.size());
for(m=1;m<=r;m++)
if(Sh(m))lm=m;
/* while(l<r)
{
m=l+r>>1;
if(Sh(m))lm=m,l=m+1;
else r=m-1;
}*/
cout<<lm;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |