Submission #57997

# Submission time Handle Problem Language Result Execution time Memory
57997 2018-07-16T15:28:36 Z gs18115 구간 성분 (KOI15_interval) C++14
0 / 100
20 ms 676 KB
#include<iostream>
#include<set>
using namespace std;
typedef long long LL;
set<LL>S;
char A[9999],B[9999];
LL Al,Bl,i,j,k;
LL H[30];
int main()
{
    for(i=25,k=1;i>=0;i--,k*=3)
        H[i]=k;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>A>>B;
    for(Al=0;A[Al];Al++);
    for(Bl=0;B[Bl];Bl++);
    for(i=min(Al,Bl);i>0;i--)
    {
        S.clear();
        k=0;
        for(j=0;j<i;j++)
            k+=H[A[j]-97];
        S.insert(k);
        for(j=0;j<Al-i;j++)
        {
            k+=H[A[j+i]-97]-H[A[j]-97];
            S.insert(k);
        }
        k=0;
        for(j=0;j<i;j++)
            k+=H[B[j]-97];
        if(S.find(k)!=S.end())
        {
            cout<<i<<endl;
            return 0;
        }
        for(j=0;j<Bl-i;j++)
        {
            k+=H[B[j+i]-97]-H[B[j]-97];
            if(S.find(k)!=S.end())
            {
                cout<<i<<endl;
                return 0;
            }
        }
    }
    cout<<0<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 408 KB Output is correct
2 Incorrect 3 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -