我丢,我也是,我洛谷RE,但是本地用洛谷的错误点数据,可以过
by fzdkx @ 2024-03-27 19:29:54
public static void main(String[] args) {
new Thread(null,()->{
你的代码 },"**随意命名**",**给定一个内存空间大小要尽量大**).start();
}这样就能过
我的代码如下
```java
import java.util.Scanner;
public class 火星人 {
static int n,k=0,ans=0,flag=0;
static int m;
static String S;
static int [] f=new int[10001];
static int []a=new int[10001];
static int []b=new int[10001];
static void dfs(int sum){
if (ans==m+1){
return;
}
if (sum==n){
ans++;
if (ans==m+1){
for (int i=0;i<n;i++){
System.out.print(a[i]+" ");
}
}
flag=1;
return;
}
for (int i=1;i<=n;i++){
if (f[i]==0){
if (flag==0)i=b[sum];
f[i]=1;
a[sum]=i;
dfs(sum+1);
f[i]=0;
}
}
}
public static void main(String[] args) {
new Thread(null,()->{
Scanner scanner=new Scanner(System.in);
n=scanner.nextInt();
m=scanner.nextInt();
for (int i=0;i<n;i++){
b[i]=scanner.nextInt();
}
dfs(0);
},"tengzhifei",2<<24).start();
}
}
```
by tengzhifei @ 2024-05-08 21:16:46
@[fzdkx](/user/1293520) @[fzdkx](/user/1293520)这样就可以了
by tengzhifei @ 2024-05-08 21:17:48
@[tengzhifei](/user/893780) 好的好的,感谢
by fzdkx @ 2024-05-09 23:11:20