数组开大一点
by __zzy__ @ 2021-12-28 16:07:21
这是代码:
```java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class P1245 {
static int n;
static String str;
static ROOT root;
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(in.readLine());
str = in.readLine();
root = new ROOT();
for (int i = 0; i < n; i++)
createtree(in.readLine(),root);
dfs(0,new StringBuilder(),root);
System.out.print("No Solutions!");
in.close();
}
private static void dfs(int index, StringBuilder ans, ROOT roots) {
if (index == str.length()){
if(roots.end!=0){
System.out.print(ans);
System.exit(0);
}
return;
}
int len = str.charAt(index) =='5'?2:3,start = (str.charAt(index) - '0')*3 - 2;
if(str.charAt(index)>'5')
start --;
if (roots.end != 0)
dfs(index, new StringBuilder(ans).append(" "), root);
while (len!=0){
if (roots.next[start-1] !=null){
dfs(index+1,new StringBuilder(ans).append((char)('a' + (start - 1))),roots.next[start - 1]);
}
start++;
len --;
}
}
private static void createtree(String next, ROOT root) {
for (int i = 0; i < next.length(); i++) {
if (root.next[next.charAt(i) - 'a'] == null)
root.next[next.charAt(i) - 'a'] = new ROOT();
root = root.next[next.charAt(i) - 'a'];
root.count++;
}
root.end++;
}
}
class ROOT {
int count, end;
ROOT next[] = new ROOT[26];
public ROOT() {
this.count = 0;
this.end = 0;
}
}
//蒟蒻求助,代码很丑请谅解qaq
by 修心 @ 2021-12-28 16:08:27
@[__zzy__](/user/478552) 没有用啊
by 修心 @ 2021-12-28 16:08:47
@[修心](/user/436016) 我以为你用C++提交的..一般RE都是数组访问越界了
by __zzy__ @ 2021-12-28 16:09:38
@[__zzy__](/user/478552) 有解决方法吗,或者有第九个点的测试数据?一直re好难受
by 修心 @ 2021-12-28 16:11:21
我也开始re了qwq
by Aoung @ 2021-12-29 01:04:15
```
12
117226796877242968172117228428477242
care
for
yourself
you
are
careful
ful
rself
f
el
s
```
最后一个我也不知道,我只知道前11个
by Acoipp @ 2022-08-29 08:33:28