Submission #48812

# Submission time Handle Problem Language Result Execution time Memory
48812 2018-05-19T04:35:58 Z leehosu01 구간 성분 (KOI15_interval) C++17
0 / 100
18 ms 1168 KB
#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]]++;
    for(i=len;i<A.size();i++)
    {
        inA.insert(im);
        im[A[i]]++;
        if(--im[A[i-len]]==0)
            im.erase(A[i-len]);
    }
    im.clear();
    for(i=0;i<len;i++)im[B[i]]++;
    for(i=len;i<B.size();i++)
    {
        if(inA.find(im)!=inA.end())return 1;
        im[B[i]]++;
        if(--im[B[i-len]]==0)
            im.erase(B[i-len]);
    }
    return 0;
}
int main()
{
    cin>>A>>B;
    int l=1,m,lm=0,r=min((int)A.size(),(int)B.size());
    while(l<r)
    {

        m=l+r>>1;
        if(Sh(m))lm=m,l=m+1;
        else r=m-1;
    }
    cout<<lm;
}

Compilation message

interval.cpp: In function 'bool Sh(ll)':
interval.cpp:12:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=len;i<A.size();i++)
               ~^~~~~~~~~
interval.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=len;i<B.size();i++)
               ~^~~~~~~~~
interval.cpp: In function 'int main()':
interval.cpp:37:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         m=l+r>>1;
           ~^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Incorrect 3 ms 488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 736 KB Output is correct
2 Incorrect 4 ms 736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1168 KB Output isn't correct
2 Halted 0 ms 0 KB -