답안 #71105

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71105 2018-08-24T06:58:01 Z khohko 구간 성분 (KOI15_interval) C++17
7 / 100
1000 ms 44132 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)(233))
#define MOD ((ll)(1e9+7))
#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];
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]];
			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]];
			hs%=MOD;
			pas=max(pas,mp[hs]);
		}
	}
	cout<<pas;


}

Compilation message

interval.cpp: In function 'int main()':
interval.cpp:32:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<s.size(); i++){
               ~^~~~~~~~~
interval.cpp:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=i; j<s.size(); j++){
                ~^~~~~~~~~
interval.cpp:35:15: warning: array subscript has type 'char' [-Wchar-subscripts]
    hs+=pw[s[j]];
               ^
interval.cpp:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<t.size(); i++){
               ~^~~~~~~~~
interval.cpp:42:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=i; j<t.size(); j++){
                ~^~~~~~~~~
interval.cpp:43:15: warning: array subscript has type 'char' [-Wchar-subscripts]
    hs+=pw[t[j]];
               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 5 ms 656 KB Output is correct
3 Correct 4 ms 656 KB Output is correct
4 Correct 6 ms 1148 KB Output is correct
5 Correct 6 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 206 ms 13052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 44132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1065 ms 44132 KB Time limit exceeded
2 Halted 0 ms 0 KB -