Submission #48815

# Submission time Handle Problem Language Result Execution time Memory
48815 2018-05-19T04:44:56 Z leehosu01 구간 성분 (KOI15_interval) C++17
0 / 100
1000 ms 1600 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]]++;
    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]]++;
    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());
    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

interval.cpp: In function 'bool Sh(ll)':
interval.cpp:13:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=len;i<A.size();i++)
               ~^~~~~~~~~
interval.cpp:22: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:34:9: warning: unused variable 'l' [-Wunused-variable]
     int l=1,m,lm=0,r=min((int)A.size(),(int)B.size());
         ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 540 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 212 ms 876 KB Output is correct
2 Correct 75 ms 876 KB Output is correct
3 Correct 15 ms 876 KB Output is correct
4 Incorrect 8 ms 876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 900 ms 1352 KB Output is correct
2 Execution timed out 1088 ms 1600 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 216 ms 1600 KB Output is correct
2 Execution timed out 1078 ms 1600 KB Time limit exceeded
3 Halted 0 ms 0 KB -