ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#210931 | #2067. 肉夹馍 | FHL | 0 | 0ms | 1240kb | C++11 | 1.1kb | 2024-08-08 11:32:14 | 2024-08-08 14:28:57 |
answer
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
void solve(const string& s) {
int n = s.size(), len = 0, i = 1, lps[n];
while (i < n) {
if (s[i] == s[len]) {
len++;
lps[i] = len;
i++;
}
else {
if (len != 0) len = lps[len - 1];
else {
lps[i] = 0;
i++;
}
}
}
for (int k = 0; k < n; k ++ ) {
if ((k + 1) / 2 < lps[k]) {
if ((k + 1) % 2 != 0) lps[k] /= 2;
else lps[k] = 0;
}
else if((k + 1) / 2 == lps[k])
if ((k + 1) % 2 == 0)
lps[k] = 0;
}
bool flag = true;
for (int k = 0; k < s.size() - 1; k ++ )
if (s[k] != s[k + 1])
flag = false;
if (flag) {
for (int k = 0; k < s.size(); k ++ ) cout << k / 2 << " ";
return;
}
for (int k = 0 ;k < n; k ++ ) cout << lps[k] << " " ;
}
string s;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
solve(s);
cout << "\n";
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1240kb
input:
qpbvqpbvqpbvavdqpbvqpbvqpbvavdqpbvqpbvqpbvavdfnfninqpbvqpbvqpbvavdqpbvqpbvqpbvavdqpbvqpbvqpbvavd
output:
62 0 0 0 1 2 3 0 2 0 3 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 1...
result:
wrong answer 1st words differ - expected: '0', found: '62'
Subtask #2:
score: 0
Skipped
Subtask #3:
score: 0
Skipped
Subtask #4:
score: 0
Skipped