답안 #58842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58842 2018-07-19T15:50:28 Z gs18115 구간 성분 (KOI15_interval) C++14
100 / 100
293 ms 764 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]={5333,
16339,
99023,
3434983,
32758927,
273598275,
783265898,
2147483647,
8590123453LL,
36072100141LL,
928635896239LL,
2839728935982LL,
8237598263985LL,
23789427983544LL,
92738927398529LL,
273956289356923LL,
639875298375982LL,
3289572893758923LL,
9273487523645628LL,
37598237958232352LL,
82379562375623328LL,
237589237958623293LL,
782365892375982739LL,
2387429837598236234LL,
9223372036854775807LL};
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 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 3 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 540 KB Output is correct
2 Correct 18 ms 540 KB Output is correct
3 Correct 2 ms 728 KB Output is correct
4 Correct 3 ms 728 KB Output is correct
5 Correct 26 ms 728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 728 KB Output is correct
2 Correct 115 ms 728 KB Output is correct
3 Correct 102 ms 728 KB Output is correct
4 Correct 92 ms 728 KB Output is correct
5 Correct 97 ms 728 KB Output is correct
6 Correct 94 ms 760 KB Output is correct
7 Correct 106 ms 760 KB Output is correct
8 Correct 103 ms 760 KB Output is correct
9 Correct 102 ms 760 KB Output is correct
10 Correct 103 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 760 KB Output is correct
2 Correct 228 ms 764 KB Output is correct
3 Correct 183 ms 764 KB Output is correct
4 Correct 10 ms 764 KB Output is correct
5 Correct 293 ms 764 KB Output is correct