CSES - Leirikisa 1 - Results
Submission details
Task:slasticar
Sender:zxc
Submission time:2016-07-27 16:20:18 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.05 sdetails
#20.05 sdetails
#30.05 sdetails
#40.05 sdetails
#50.05 sdetails
#60.15 sdetails
#70.16 sdetails
#80.15 sdetails
#90.16 sdetails
#100.16 sdetails
#110.17 sdetails
#120.16 sdetails
#130.14 sdetails
#140.16 sdetails
#150.17 sdetails
#160.16 sdetails
#170.15 sdetails
#180.15 sdetails

Compiler report

input/code.cpp: In function 'bool cmp(int, int)':
input/code.cpp:15:9: warning: unused variable 'q' [-Wunused-variable]
     int q = hi;
         ^

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ha[101010];
ll ex[101010];
int t[101010];
int n;

ll getHash(int a, int b) {
    return ha[b+1] - ex[b-a+1]*ha[a];
}
bool cmp(int a, int b) {
    int lo = 0;
    int hi = min(n-a-1, n-b-1);
    int q = hi;
    int best = -1;
    while(lo <= hi) {
	int mid = (lo+hi)/2;
	if(getHash(a, mid) == getHash(b, mid)) {
	    best = mid;
	    lo = mid+1;
	}
	else {
	    hi = mid-1;
	}
    }
    if(best == hi) return 0;
    return t[a+best+1] < t[b+best+1];
}
int sa[101010];
int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ex[0] = 1;
    for(int i = 1; i < 101010; ++i) {
	ex[i] = ex[i-1]*i;
    }
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i = 0; i < n; ++i) {
	char q;
	cin>>q;
	t[i] = q;
	ha[i+1] = ha[i]*107 + t[i];
    }
    for(int i = 0; i < n; ++i) {
	sa[i] = i;
    }
    sort(sa, sa+n, cmp); 
    int m;
    cin>>m;
    for(int i = 0; i < m; ++i) {
	string s;
	cin>>s;
    }
}

Test details

Test 1

Verdict:

input
7
1090901
4
87650
0901
...

correct output
7
10
3
4

user output
(empty)

Test 2

Verdict:

input
10
5821052680
4
210526
2105
...

correct output
8
6
3
9

user output
(empty)

Test 3

Verdict:

input
3
001
1
11

correct output
4

user output
(empty)

Test 4

Verdict:

input
1000
765663201315813856165248633340...

correct output
837
802
756
520
611
...

user output
(empty)

Test 5

Verdict:

input
1000
407400373060682341208822230817...

correct output
833
1026
774
855
850
...

user output
(empty)

Test 6

Verdict:

input
100000
013000232021021133321211023303...

correct output
133418
133429
133363
133433
132893
...

user output
(empty)

Test 7

Verdict:

input
95625
020133223223332232212222000200...

correct output
95625
95625
119412
119573
95625
...

user output
(empty)

Test 8

Verdict:

input
95625
213030223200121020313233121002...

correct output
95625
95625
95625
119439
119527
...

user output
(empty)

Test 9

Verdict:

input
100000
000000000000000000000000000000...

correct output
399997
1699880
799979
1499909
2099810
...

user output
(empty)

Test 10

Verdict:

input
100000
100001000110002100031000410005...

correct output
12579
29265
117017
58854
45109
...

user output
(empty)

Test 11

Verdict:

input
100000
000000000000000000000000000000...

correct output
100000
999964
2399747
1999829
799979
...

user output
(empty)

Test 12

Verdict:

input
100000
700007000170002700037000470005...

correct output
55793
14829
33421
25742
27073
...

user output
(empty)

Test 13

Verdict:

input
100000
000000000000000000000000000000...

correct output
536065
2408088
2467498
505724
1480556
...

user output
(empty)

Test 14

Verdict:

input
100000
110010000011111110101001001001...

correct output
173282
2539
134066
60515
150056
...

user output
(empty)

Test 15

Verdict:

input
100000
000000000000000000000000000000...

correct output
1630830
1986210
2065604
1394768
1479918
...

user output
(empty)

Test 16

Verdict:

input
100000
000000000000000000000000000000...

correct output
1699880
1199945
1899847
1299934
699985
...

user output
(empty)

Test 17

Verdict:

input
100000
000001000010000000000000000000...

correct output
296
296
1079
153
46303
...

user output
(empty)

Test 18

Verdict:

input
100000
100101110001121001012120210110...

correct output
150479
116882
153076
180545
182057
...

user output
(empty)