답안 #71144

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71144 2018-08-24T07:19:36 Z khohko 구간 성분 (KOI15_interval) C++17
61 / 100
1000 ms 43820 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];
unordered_set<ll> mp[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].insert(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']++];
			if(mp[j-i].find(hs)!=mp[j-i].end())
				pas=max(pas,j-i+1);
		}
	}

	cout<<pas;


}

Compilation message

interval.cpp: In function 'int main()':
interval.cpp:34:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<s.size(); i++){
               ~^~~~~~~~~
interval.cpp:37:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=i; j<s.size(); j++){
                ~^~~~~~~~~
interval.cpp:44:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<t.size(); i++){
               ~^~~~~~~~~
interval.cpp:47:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=i; j<t.size(); j++){
                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1092 KB Output is correct
2 Correct 5 ms 1128 KB Output is correct
3 Correct 6 ms 1204 KB Output is correct
4 Correct 6 ms 1404 KB Output is correct
5 Correct 7 ms 1404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 4576 KB Output is correct
2 Correct 48 ms 5380 KB Output is correct
3 Correct 18 ms 5380 KB Output is correct
4 Correct 10 ms 5380 KB Output is correct
5 Correct 70 ms 6276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 461 ms 21352 KB Output is correct
2 Correct 408 ms 22048 KB Output is correct
3 Correct 400 ms 22092 KB Output is correct
4 Correct 430 ms 22092 KB Output is correct
5 Correct 487 ms 22092 KB Output is correct
6 Correct 457 ms 22092 KB Output is correct
7 Correct 537 ms 22092 KB Output is correct
8 Correct 463 ms 22252 KB Output is correct
9 Correct 373 ms 22252 KB Output is correct
10 Correct 442 ms 22252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 182 ms 22252 KB Output is correct
2 Execution timed out 1086 ms 43820 KB Time limit exceeded
3 Halted 0 ms 0 KB -