ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#210908 | #2067. 肉夹馍 | shiruiheng | 30 | 7ms | 1248kb | C++11 | 1.3kb | 2024-08-08 09:48:08 | 2024-08-08 14:27:51 |
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//using LL = __int128
#define pi pair<ll, ll>
#define N 2222222
#define base 1000000093
#define mod 1234429061
int n;
ll h[N], p[N] = {1};
char s[N];
bool cmp(int l, int r, int x, int y){
if(x <= r)
return false;
for(int i = l, j = x ; i <= r ; i++, j++)
if(s[i] != s[j])
return false;
return true;
}
ll calc(ll l, ll r){
return ((h[r] - h[l - 1] * p[r - l + 1] % mod) % mod + mod) % mod;
}
void debug(int l, int r){
cerr << "\n" << l << " " << r << " " << calc(l, r) << "\n";
}
bool check(int tot, int len){
//debug(1, len);
//debug(tot - len + 1, tot);
return calc(1, len) == calc(tot - len + 1, tot);
}
int main(){
scanf("%s", s + 1);
n = strlen(s + 1);
if(n <= -100){
for(int i = 1 ; i <= n ; i++)
for(int len = (i - 1) / 2 ; len >= 0 ; len--){
if(cmp(1, len, i - len + 1, i)){
printf("%d ", len);
break;
}
}
return 0;
}
if(n <= 3000){
for(int i = 1 ; i <= n ; i++){
h[i] = (h[i - 1] * base + s[i]) % mod;
p[i] = p[i - 1] * base % mod;
}
for(int i = 1 ; i <= n ; i++){
int l = 0, r = ((i - 1) >> 1);
for(int j = r ; j >= l ; j--){
if(check(i, j)){
printf("%d ", j);
break;
}
}
}
return 0;
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 1188kb
input:
qpbvqpbvqpbvavdqpbvqpbvqpbvavdqpbvqpbvqpbvavdfnfninqpbvqpbvqpbvavdqpbvqpbvqpbvavdqpbvqpbvqpbvavd
output:
0 0 0 0 1 2 3 0 1 2 3 4 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...
result:
ok 96 tokens
Test #2:
score: 0
Accepted
time: 1ms
memory: 1192kb
input:
wfalgbgweavpwhfahfewhavweahuwbvbqvuivhuiaehufuaeuvdafuivjafislfhbibcuuiabcuibsv
output:
0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 79 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 1192kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
output:
0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 ...
result:
ok 100 tokens
Subtask #2:
score: 20
Accepted
Test #4:
score: 20
Accepted
time: 0ms
memory: 1232kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 ...
result:
ok 3000 tokens
Test #5:
score: 0
Accepted
time: 0ms
memory: 1236kb
input:
cjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcjcj...
output:
0 0 1 0 1 2 3 2 3 4 5 4 5 6 7 6 7 8 9 8 9 10 11 10 11 12 13 12 13 14 15 14 15 16 17 16 17 18 19 18 1...
result:
ok 3000 tokens
Test #6:
score: 0
Accepted
time: 6ms
memory: 1236kb
input:
ckcckckcckcckckcckcckckcckcckckcsdvhckcckckcckcckckcckcckckcckcckckcsdvhckcckckcckcckckcckcckckcckcc...
output:
0 0 1 1 2 1 2 3 4 2 3 4 5 6 7 3 4 5 6 4 5 6 7 8 9 10 11 12 13 14 15 8 0 0 0 0 1 2 3 4 5 6 7 8 9 10 1...
result:
ok 2828 tokens
Subtask #3:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 1248kb
input:
aocnsaosashoicfaaocnsaosashoicfaqowfwpqgvqvhoabcdoawaocnsaosashoicfaaocnsaosashoicfaqowfwpqgvqvhoabc...
output:
result:
wrong answer Unexpected EOF in the participants output
Subtask #4:
score: 0
Skipped