답안 #57979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57979 2018-07-16T15:04:46 Z gs18115 구간 성분 (KOI15_interval) C++14
0 / 100
16 ms 680 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]={0,1,13,97,23189,44417,45139,65437,5059,3931,4523,14639,20021,32303,53161,63773,75679,59183,44887,443,2789,5569,8431,12251,15443,18199,95621};
int main()
{
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Incorrect 3 ms 548 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 680 KB Output is correct
2 Incorrect 7 ms 680 KB Output isn't correct
3 Halted 0 ms 0 KB -