# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71112 | khohko | 구간 성분 (KOI15_interval) | C++17 | 1092 ms | 64316 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define MAX ((ll)(1e12+100))
#define MX ((ll)(1e6+100))
#define ARRS ((ll)(2e6+100))
#define HS ((ll)(1049))
#define MOD ((ll)(1000000861))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;
string s,t;
ll pw[ARRS];
unordered_map<ll,ll> mp;
int main(){
#ifdef KHOKHO
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
cin>>s>>t;
pw[0]=1;
for(int i=1; i<500; i++)pw[i]=(pw[i-1]*HS)%MOD;
ll pas=0;
for(int i=0; i<s.size(); i++){
ll hs=0;
for(int j=i; j<s.size(); j++){
hs+=pw[s[j]-'a'+1];
if(hs>MOD)
hs-=MOD;
mp[hs]=j-i+1;
}
}
for(int i=0; i<t.size(); i++){
ll hs=0;
for(int j=i; j<t.size(); j++){
hs+=pw[t[j]-'a'+1];
if(hs>MOD)
hs-=MOD;
pas=max(pas,mp[hs]);
}
}
cout<<pas;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |