用户输出
2
1 2
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#20465 | #1058. JM的荧光棒工厂 | Accepted | 100 | 123 ms | 2196 K | C++ 11 (NOI) / 1.2 K | q3540555 | 2019-07-22 15:25:39 |
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define spause() system("pause")
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> prdd;
typedef map<int, int> mpdd;
const int dinf = 0x7fffffff;
const llong llinf = 0x7fffffffffffffff;
const int p = 998244353;
llong starttime;
int fail[270000], sl, ans;
string str;
vector<int> brds;
void mfail() {
for (int i = 1, j = 0; i < sl; i++) {
while (j && str[i] != str[j]) j = fail[j - 1];
if (str[i] == str[j])
fail[i] = ++j;
else
fail[i] = 0;
}
}
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
cin >> str;
// starttime = clock();
ans = sl = str.length();
mfail();
while (ans > 1) {
ans = fail[ans - 1];
if (ans > 0)
brds.push_back(ans);
}
// cout << "\nDebug Info: " << clock() - starttime << " ms passed!\n";
printf("%u\n", brds.size());
for (int i = brds.size() - 1; i >= 0; i--) printf("%d ", brds.at(i));
spause();
return 0;
}
用户输出
11
1 2 3 4 5 6 7 8 9 10 11
系统信息
Exited with return code 0
用户输出
7
7 14 21 28 35 42 49
系统信息
Exited with return code 0
用户输出
5
1 3 5 16 27
系统信息
Exited with return code 0
用户输出
4
1 7 13 19
系统信息
Exited with return code 0
用户输出
1
2
系统信息
Exited with return code 0
用户输出
2
2 8
系统信息
Exited with return code 0
abababababababababababababababababababababababababababababababababababababababababababababababababab
<199902 bytes omitted>
99999
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 6
<644351 bytes omitted>
用户输出
99999
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84
<644321 bytes omitted>
系统信息
Exited with return code 0
abbbbbbbbbabbbbbabbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbabbbbabbbabababbbbbbabbabbbbbbb
<199653 bytes omitted>
用户输出
1
53
系统信息
Exited with return code 0
utututututututututututututututututututututututututututututututututututututututututututututututututut
<199901 bytes omitted>
99999
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65
<644346 bytes omitted>
用户输出
99999
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 8
<644316 bytes omitted>
系统信息
Exited with return code 0
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
<199902 bytes omitted>
199999
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<1288797 bytes omitted>
用户输出
199999
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 4
<1288767 bytes omitted>
系统信息
Exited with return code 0
axysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxysaxys
<199902 bytes omitted>
49999
4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120
<322128 bytes omitted>
用户输出
49999
4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148
<322098 bytes omitted>
系统信息
Exited with return code 0