# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
71158 |
2018-08-24T07:28:22 Z |
khohko |
구간 성분 (KOI15_interval) |
C++17 |
|
234 ms |
26476 KB |
#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[50][2000];
vector<ll> mp[2000];
vector<ll> mp1[2000];
ll ct[50];
int main(){
#ifdef KHOKHO
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
cin>>s>>t;
for(int i=0; i<40; i++)
for(int j=0; j<1600; j++)
pw[i][j]=(((ll)rand()<<48ll)+((ll)rand()<<32ll)+((ll)rand()<<16ll)+(ll)rand());
int pas=0;
for(int i=0; i<s.size(); i++){
ll hs=0;
for(int i=0; i<40; i++)ct[i]=0;
for(int j=i; j<s.size(); j++){
hs^=pw[s[j]-'a'][ct[s[j]-'a']++];
mp[j-i].pb(hs);
// mp[hs]=j-i+1;
}
}
for(int i=0; i<t.size(); i++){
ll hs=0;
for(int i=0; i<40; i++)ct[i]=0;
for(int j=i; j<t.size(); j++){
hs^=pw[t[j]-'a'][ct[t[j]-'a']++];
mp1[j-i].pb(hs);
//if(mp[j-i].find(hs)!=mp[j-i].end())
//pas=max(pas,j-i+1);
}
}
for(int i=1600; i>=0; i--){
sort(mp[i].begin(),mp[i].end());
sort(mp1[i].begin(),mp1[i].end());
ll j=0;
for(int k=0; k<mp[i].size(); k++){
while(j<mp1[i].size()&&mp1[i][j]<mp[i][k])j++;
//cout<<mp[i][k]<<" "<<mp1[i][j]<<endl;
if(j<mp1[i].size()&&mp[i][k]==mp1[i][j])pas=max(pas,i+1);
}
if(pas)break;
}
cout<<pas;
}
Compilation message
interval.cpp: In function 'int main()':
interval.cpp:35:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<s.size(); i++){
~^~~~~~~~~
interval.cpp:38:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=i; j<s.size(); j++){
~^~~~~~~~~
interval.cpp:45:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<t.size(); i++){
~^~~~~~~~~
interval.cpp:48:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=i; j<t.size(); j++){
~^~~~~~~~~
interval.cpp:59:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int k=0; k<mp[i].size(); k++){
~^~~~~~~~~~~~~
interval.cpp:60:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j<mp1[i].size()&&mp1[i][j]<mp[i][k])j++;
~^~~~~~~~~~~~~~
interval.cpp:62:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(j<mp1[i].size()&&mp[i][k]==mp1[i][j])pas=max(pas,i+1);
~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1020 KB |
Output is correct |
2 |
Correct |
5 ms |
1124 KB |
Output is correct |
3 |
Correct |
6 ms |
1200 KB |
Output is correct |
4 |
Correct |
6 ms |
1236 KB |
Output is correct |
5 |
Correct |
6 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
3532 KB |
Output is correct |
2 |
Correct |
16 ms |
3532 KB |
Output is correct |
3 |
Correct |
14 ms |
3868 KB |
Output is correct |
4 |
Correct |
10 ms |
3872 KB |
Output is correct |
5 |
Correct |
26 ms |
4000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
11984 KB |
Output is correct |
2 |
Correct |
92 ms |
11996 KB |
Output is correct |
3 |
Correct |
93 ms |
11996 KB |
Output is correct |
4 |
Correct |
89 ms |
12012 KB |
Output is correct |
5 |
Correct |
98 ms |
12012 KB |
Output is correct |
6 |
Correct |
83 ms |
12016 KB |
Output is correct |
7 |
Correct |
87 ms |
12016 KB |
Output is correct |
8 |
Correct |
90 ms |
12016 KB |
Output is correct |
9 |
Correct |
91 ms |
12128 KB |
Output is correct |
10 |
Correct |
89 ms |
12128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
17388 KB |
Output is correct |
2 |
Correct |
207 ms |
26476 KB |
Output is correct |
3 |
Correct |
195 ms |
26476 KB |
Output is correct |
4 |
Correct |
88 ms |
26476 KB |
Output is correct |
5 |
Correct |
234 ms |
26476 KB |
Output is correct |