CSES - APIO 2014 - Results
Submission details
Task:Palindromes
Sender:ollpu
Submission time:2019-03-23 19:38:33 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#1ACCEPTED0.03 s1, 2, 3, 4, 5details
#2ACCEPTED0.02 s1, 2, 3, 4, 5details
#30.02 s1, 2, 3, 4, 5details
#4ACCEPTED0.02 s1, 2, 3, 4, 5details
#5ACCEPTED0.02 s1, 2, 3, 4, 5details
#6ACCEPTED0.01 s1, 2, 3, 4, 5details
#7ACCEPTED0.02 s1, 2, 3, 4, 5details
#8ACCEPTED0.02 s1, 2, 3, 4, 5details
#9ACCEPTED0.02 s1, 2, 3, 4, 5details
#100.02 s1, 2, 3, 4, 5details
#11ACCEPTED0.03 s1, 2, 3, 4, 5details
#120.02 s1, 2, 3, 4, 5details
#130.02 s1, 2, 3, 4, 5details
#140.02 s1, 2, 3, 4, 5details
#15ACCEPTED0.02 s1, 2, 3, 4, 5details
#16ACCEPTED0.02 s1, 2, 3, 4, 5details
#170.02 s1, 2, 3, 4, 5details
#180.02 s1, 2, 3, 4, 5details
#190.01 s1, 2, 3, 4, 5details
#200.02 s1, 2, 3, 4, 5details
#210.02 s1, 2, 3, 4, 5details
#220.02 s1, 2, 3, 4, 5details
#230.02 s1, 2, 3, 4, 5details
#240.03 s1, 2, 3, 4, 5details
#250.02 s1, 2, 3, 4, 5details
#260.03 s1, 2, 3, 4, 5details
#270.02 s1, 2, 3, 4, 5details
#280.02 s1, 2, 3, 4, 5details
#290.02 s1, 2, 3, 4, 5details
#30ACCEPTED0.02 s1, 2, 3, 4, 5details
#31ACCEPTED0.03 s1, 2, 3, 4, 5details
#32ACCEPTED0.02 s1, 2, 3, 4, 5details
#330.90 s2, 3, 4, 5details
#340.52 s2, 3, 4, 5details
#35--2, 3, 4, 5details
#360.17 s2, 3, 4, 5details
#37--2, 3, 4, 5details
#38--2, 3, 4, 5details
#39ACCEPTED0.05 s2, 3, 4, 5details
#400.90 s2, 3, 4, 5details
#410.10 s2, 3, 4, 5details
#42ACCEPTED0.04 s2, 3, 4, 5details
#43ACCEPTED0.03 s2, 3, 4, 5details
#44ACCEPTED0.06 s2, 3, 4, 5details
#45--3, 4, 5details
#46--3, 4, 5details
#47--3, 4, 5details
#48--3, 4, 5details
#49--3, 4, 5details
#50--3, 4, 5details
#51--3, 4, 5details
#52ACCEPTED0.65 s3, 4, 5details
#53ACCEPTED0.66 s3, 4, 5details
#54--3, 4, 5details
#55--4, 5details
#56--4, 5details
#57--4, 5details
#58--4, 5details
#59--4, 5details
#60--4, 5details
#61--4, 5details
#62--4, 5details
#63--4, 5details
#64--4, 5details
#65--5details
#66--5details
#67--5details
#68--5details
#69--5details
#70--5details
#71--5details
#72--5details
#73--5details
#74--5details
#75--5details
#76--5details

Code

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
const int A = 37;
const int B = 1181726167;
int h[301010];
int Ap[301010];
int gh(int a, int b) {
  a++; b++;
  return (h[b]+B-h[a-1]*Ap[b-a+1]%B)%B;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Ap[0] = 1;
  for (int i = 1; i < 301010; ++i) {
    Ap[i] = Ap[i-1]*A%B;
  }
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 1; i <= n; ++i) {
    h[i] = h[i-1]*A%B + s[i-1];
    h[i] %= B;
  }
  long res = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      bool f = 1;
      for (int k = 0; k <= (j-i)/2; ++k) {
        if (s[i+k] != s[j-k]) {
          f=0; break;
        }
      }
      if (f) {
        long ur = 0;
        int sz = j-i+1;
        for (int x = 0; x < n-sz+1; ++x) {
          bool f = gh(i, j) == gh(x, x+sz-1);
          ur += f*sz;
        }
        res = max(res, ur);
      }
    }
  }
  cout << res << endl;
}

Test details

Test 1

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
abacaba

correct output
7

user output
7

Test 2

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
www

correct output
4

user output
4

Test 3

Group: 1, 2, 3, 4, 5

Verdict:

input
abacababa

correct output
9

user output
7

Test 4

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
r

correct output
1

user output
1

Test 5

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
xd

correct output
1

user output
1

Test 6

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
dd

correct output
2

user output
2

Test 7

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
opo

correct output
3

user output
3

Test 8

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
opoo

correct output
3

user output
3

Test 9

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
abacabadabacaba

correct output
15

user output
15

Test 10

Group: 1, 2, 3, 4, 5

Verdict:

input
xxxxxyxxxxyxxxxx

correct output
24

user output
18

Test 11

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
xxxyxxxyzzzabcdxxdcba

correct output
10

user output
10

Test 12

Group: 1, 2, 3, 4, 5

Verdict:

input
qpppppppwowpppppq

correct output
24

user output
16

Test 13

Group: 1, 2, 3, 4, 5

Verdict:

input
mqmwmemrmtymmmmmmmmqwertyeeeee...

correct output
25

user output
13

Test 14

Group: 1, 2, 3, 4, 5

Verdict:

input
mqmwmmmmmemrmtymmmmmmmmqwertye...

correct output
28

user output
18

Test 15

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
abcdefghijklmnopqrstuvwxyzz

correct output
2

user output
2

Test 16

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
abcdefghijklmnopqrstuvwxyz

correct output
1

user output
1

Test 17

Group: 1, 2, 3, 4, 5

Verdict:

input
apiodpdpdpdpdpgoodchallenge

correct output
15

user output
9

Test 18

Group: 1, 2, 3, 4, 5

Verdict:

input
pdpdpdpxdpdpdxdpdpdx

correct output
18

user output
13

Test 19

Group: 1, 2, 3, 4, 5

Verdict:

input
jejejejejejejejejejejejejejeje...

correct output
1176

user output
95

Test 20

Group: 1, 2, 3, 4, 5

Verdict:

input
wzwzwzwzwzwzwzwzwzwzwzwzwzwzwz...

correct output
1225

user output
97

Test 21

Group: 1, 2, 3, 4, 5

Verdict:

input
qsqsqsqsqsqsqianananananananan...

correct output
136

user output
34

Test 22

Group: 1, 2, 3, 4, 5

Verdict:

input
hsoqhdnglglqqhqhqhqhqhqhqmyiyi...

correct output
45

user output
17

Test 23

Group: 1, 2, 3, 4, 5

Verdict:

input
oooooooooooooooooooooooooooooo...

correct output
2500

user output
124

Test 24

Group: 1, 2, 3, 4, 5

Verdict:

input
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

correct output
380

user output
44

Test 25

Group: 1, 2, 3, 4, 5

Verdict:

input
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...

correct output
2304

user output
112

Test 26

Group: 1, 2, 3, 4, 5

Verdict:

input
gggggggggtoooooooooccwwwwwwwww...

correct output
110

user output
26

Test 27

Group: 1, 2, 3, 4, 5

Verdict:

input
vlvivlvwvlvivlvkvlvivlvwvlvivl...

correct output
93

user output
73

Test 28

Group: 1, 2, 3, 4, 5

Verdict:

input
nbnenbnjnbnenbnxnbnenbnjnbnenb...

correct output
729

user output
66

Test 29

Group: 1, 2, 3, 4, 5

Verdict:

input
ydycydylydycydyodoycydylydycyd...

correct output
132

user output
37

Test 30

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
dzydpxreexldgbslbouxllaizermiy...

correct output
7

user output
7

Test 31

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
bpmerpingvjipwmenzzalhrsmrkmxv...

correct output
8

user output
8

Test 32

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
abbabaabbaababbabaababbaabbaba...

correct output
64

user output
64

Test 33

Group: 2, 3, 4, 5

Verdict:

input
yhyhyhyhyhyhyhyhyhyhyhyhyhyhyh...

correct output
124251

user output
995

Test 34

Group: 2, 3, 4, 5

Verdict:

input
nknknknknknknknknknknknknknknk...

correct output
38226

user output
551

Test 35

Group: 2, 3, 4, 5

Verdict:

input
oooooooooooooooooooooooooooooo...

correct output
249500

user output
(empty)

Test 36

Group: 2, 3, 4, 5

Verdict:

input
ktktktktktktktktktktktktktktkt...

correct output
5778

user output
213

Test 37

Group: 2, 3, 4, 5

Verdict:

input
gggggggggggggggggggggggggggggg...

correct output
247506

user output
(empty)

Test 38

Group: 2, 3, 4, 5

Verdict:

input
dddddddddddddddddddddddddddddd...

correct output
248004

user output
(empty)

Test 39

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
tdtytdtxtdtytdtptdtytdtxtdtytd...

correct output
973

user output
973

Test 40

Group: 2, 3, 4, 5

Verdict:

input
xfxfxfxfxfxfxfxfxfxfxfxfxfxfxf...

correct output
123753

user output
993

Test 41

Group: 2, 3, 4, 5

Verdict:

input
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...

correct output
2346

user output
267

Test 42

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
phxbzjihyzgshwcidlnkwkltarrnbv...

correct output
53

user output
53

Test 43

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
nkevzhqlzcmqmbvtbojxbbtvgsxkbh...

correct output
52

user output
52

Test 44

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
abbabaabbaababbabaababbaabbaba...

correct output
976

user output
976

Test 45

Group: 3, 4, 5

Verdict:

input
lnlnlnlnlnlnlnlnlnlnlnlnlnlnln...

correct output
12497500

user output
(empty)

Test 46

Group: 3, 4, 5

Verdict:

input
qhqhqhqhqhqhqhqhqhqhqhqhqhqhqh...

correct output
6481800

user output
(empty)

Test 47

Group: 3, 4, 5

Verdict:

input
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

correct output
25000000

user output
(empty)

Test 48

Group: 3, 4, 5

Verdict:

input
ffffffffffffffffffffffffffffff...

correct output
17816841

user output
(empty)

Test 49

Group: 3, 4, 5

Verdict:

input
xlxixlxpxlxixlxexlxixlxpxlxixl...

correct output
9945

user output
(empty)

Test 50

Group: 3, 4, 5

Verdict:

input
elelelelelelelelelelelelelelel...

correct output
504100

user output
(empty)

Test 51

Group: 3, 4, 5

Verdict:

input
afamafacafamafakafamafacafamaf...

correct output
1512930

user output
(empty)

Test 52

Group: 3, 4, 5

Verdict: ACCEPTED

input
hmdqbxxvfzcxpohuffioztrgqgxkhf...

correct output
413

user output
413

Test 53

Group: 3, 4, 5

Verdict: ACCEPTED

input
xznwghgyngrjehtffuiepaedcvdova...

correct output
428

user output
428

Test 54

Group: 3, 4, 5

Verdict:

input
abbabaabbaababbabaababbaabbaba...

correct output
7232

user output
(empty)

Test 55

Group: 4, 5

Verdict:

input
bhbhbhbhbhbhbhbhbhbhbhbhbhbhbh...

correct output
1249925001

user output
(empty)

Test 56

Group: 4, 5

Verdict:

input
ususususususususususususususus...

correct output
396337935

user output
(empty)

Test 57

Group: 4, 5

Verdict:

input
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...

correct output
2500050000

user output
(empty)

Test 58

Group: 4, 5

Verdict:

input
llllllllllllllllllllllllllllll...

correct output
1016525689

user output
(empty)

Test 59

Group: 4, 5

Verdict:

input
kvkikvklkvkikvkgkvkikvklkvkikv...

correct output
99645

user output
(empty)

Test 60

Group: 4, 5

Verdict:

input
pqpzpqpupqpzpqpbpqpzpqpupqpzpq...

correct output
78569380

user output
(empty)

Test 61

Group: 4, 5

Verdict:

input
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq...

correct output
82810000

user output
(empty)

Test 62

Group: 4, 5

Verdict:

input
vmlqjhjiwwzijupbzztlkcxbcdavxy...

correct output
3989

user output
(empty)

Test 63

Group: 4, 5

Verdict:

input
bcqqtvvdvexrttkgcbhmlhoasnlcek...

correct output
125529616

user output
(empty)

Test 64

Group: 4, 5

Verdict:

input
abbabaabbaababbabaababbaabbaba...

correct output
66664

user output
(empty)

Test 65

Group: 5

Verdict:

input
bnbnbnbnbnbnbnbnbnbnbnbnbnbnbn...

correct output
11250075000

user output
(empty)

Test 66

Group: 5

Verdict:

input
jzjzjzjzjzjzjzjzjzjzjzjzjzjzjz...

correct output
894243195

user output
(empty)

Test 67

Group: 5

Verdict:

input
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...

correct output
22499400004

user output
(empty)

Test 68

Group: 5

Verdict:

input
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...

correct output
2958163321

user output
(empty)

Test 69

Group: 5

Verdict:

input
xqxtxqxwxqxtxqxlxqxtxqxwxqxtxq...

correct output
298935

user output
(empty)

Test 70

Group: 5

Verdict:

input
zwzwzwzwzwzwzwzwzwzwzwzwzwzwzw...

correct output
1210831209

user output
(empty)

Test 71

Group: 5

Verdict:

input
hyhnhyhehyhnhyhlhyhnhyhehyhnhy...

correct output
303195156

user output
(empty)

Test 72

Group: 5

Verdict:

input
hnrootvymrwweaxjusfltkgyqyeioo...

correct output
11804

user output
(empty)

Test 73

Group: 5

Verdict:

input
yoljcehfgzraqykusrdwgqxdudzvep...

correct output
11813

user output
(empty)

Test 74

Group: 5

Verdict:

input
abbabaabbaababbabaababbaabbaba...

correct output
262144

user output
(empty)

Test 75

Group: 5

Verdict:

input
acbabcacbabcacbabcacbabcacbabc...

correct output
3750025000

user output
(empty)

Test 76

Group: 5

Verdict:

input
uptvtysodzujkjcvrzkzydggrhjjli...

correct output
184796836

user output
(empty)