Submission details
Task:Repeating substring
Sender:siiruli-admin
Submission time:2018-10-13 13:35:15 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.16 sdetails
#4ACCEPTED0.32 sdetails
#5ACCEPTED0.34 sdetails
#6ACCEPTED0.33 sdetails
#7ACCEPTED0.33 sdetails
#8ACCEPTED0.33 sdetails
#9ACCEPTED0.32 sdetails
#10ACCEPTED0.33 sdetails
#11ACCEPTED0.36 sdetails
#12UNKNOWN--details
#13UNKNOWN--details
#14UNKNOWN--details
#15UNKNOWN--details

Code

#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define PB push_back
#define N (1<<20)
#define QAQ {cout << "0";return 0; }
typedef long long ll;
const ll inf = 1000000007;
int t[N][20];

int f(int a, int b){
  int V = 0;
  //cout << "\n" << a << " " << b<< ": \n";
  for(int k=17; k>=0; --k){
  //  cout << t[a][k] << " " << t[b][k] << ", ";
    if(t[a][k] != t[b][k]) continue;
    V += (1<<k);
    a += (1<<k), b+= (1<<k);
  }
  return V;
}

int main(){
  ios::sync_with_stdio(0); cin.tie(0);
  string s; cin >> s;
	int n = s.size();
	for(int i=n; i<N; ++i) s+= "#";
	for(int i=0; i<N; ++i) t[i][0] = s[i];
	
	for(int b=0; b<=17; ++b){
	  vector<pair<ll,ll>> v;
	  for(int i=0; i<n; ++i){
	    v.PB({t[i][b] * inf + t[i+(1<<b)][b], i});
	  }
	  sort(v.begin(), v.end());
	  ll c=0, prev=0;
	  for(pair<ll, ll> p : v){
	    if(prev != p.first) prev = p.first, ++c;
	//    cout << s.substr(p.second, (1<<(b+1))) << " " << c<<  "\n";
	    t[p.second][b+1] = c;
	  }
	}
	vector<pair<ll, ll>> v;
	for(int i=0; i<n; ++i){
	  v.PB({t[i][17], i});
	}
	sort(v.begin(), v.end());
	int ml=0, V=0;
	for(int i=1; i<n; ++i){
	  int c = f(v[i-1].second, v[i].second);
	  if(c > ml) ml=c, V=v[i-1].second;
	}
	//cout << ml << " " << V << " ";
  for(int i=0; i<ml; ++i) cout << s[V+i];
}













Test details

Test 1

Verdict: ACCEPTED

input
abcdabcdabcd

correct output
abcdabcd

user output
abcdabcd

Test 2

Verdict: ACCEPTED

input
abcdefghijklmnopqrstuvwxyz

correct output
(empty)

user output
(empty)

Test 3

Verdict: ACCEPTED

input
yypqtdfbwzpfwsmjjagdjpfyqnyspk...

correct output
cqkgus

user output
cqkgus

Test 4

Verdict: ACCEPTED

input
zwnqhornqkcmioyxxtkkwrbkorncjh...

correct output
dywyvkf

user output
dywyvkf

Test 5

Verdict: ACCEPTED

input
fhnnpfcbnpnsigmvmklzvfluwvypyb...

correct output
asjzge

user output
asjzge

Test 6

Verdict: ACCEPTED

input
daqyvtkjopactcbkghijgrpjghmefa...

correct output
sowvwyy

user output
sowvwyy

Test 7

Verdict: ACCEPTED

input
ksdohlhpsupwqhoditrhvbansccnnh...

correct output
devycn

user output
devycn

Test 8

Verdict: ACCEPTED

input
edhikrxqidgjpxnyytsfzylndslhyu...

correct output
brmnvr

user output
brmnvr

Test 9

Verdict: ACCEPTED

input
hutihnlmghdovkmbelctafdqhldiyl...

correct output
bbzhpo

user output
bbzhpo

Test 10

Verdict: ACCEPTED

input
ttyameoijyqaxrkvfqkxgrwigmalxw...

correct output
cbahwtz

user output
cbahwtz

Test 11

Verdict: ACCEPTED

input
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

correct output
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

user output
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
Truncated

Test 12

Verdict: UNKNOWN

input
a

correct output
(empty)

user output
(not available)

Test 13

Verdict: UNKNOWN

input
aa

correct output
a

user output
(not available)

Test 14

Verdict: UNKNOWN

input
ab

correct output
(empty)

user output
(not available)

Test 15

Verdict: UNKNOWN

input
zz

correct output
z

user output
(not available)