用户输出
2
1 2
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#59313 | #1058. JM的荧光棒工厂 | Accepted | 100 | 103 ms | 2376 K | C++ 17 / 1.7 K | 丁丁跑卡车 | 2021-07-14 20:29:44 |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ud unsigned int
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
//#define pi 3.141592653589
#define eps 1e-9
#define F(x) ((x) / 3 + ((x) % 3 == 1 ? 0 : tb))
#define G(x) ((x) < tb ? (x)*3 + 1 : ((x)-tb) * 3 + 2)
//#define p 2173412051LL
//#define sz 2
using namespace std;
template <typename T>
void read(T &x) {
x = 0;
char ch = getchar();
ll f = 1;
while (!isdigit(ch)) {
if (ch == '-')
f *= -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - 48;
ch = getchar();
}
x *= f;
}
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
char s[200010];
int fail[200010];
void make_fail(char *, int *);
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> s;
make_fail(s, fail);
vector<int> ans;
for (int i = fail[strlen(s) - 1]; i; i = fail[i - 1]) ans.push_back(i);
reverse(ans.begin(), ans.end());
cout << ans.size() << '\n';
for (auto v : ans) cout << v << ' ';
return 0;
}
void make_fail(char *s, int *fail) {
fail[0] = 0;
for (int i = 1, j = 0; s[i]; ++i) {
while (j && s[i] != s[j]) j = fail[j - 1];
if (s[i] == s[j])
++j;
fail[i] = j;
}
}
用户输出
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