牛客623827963号 level
获赞
1
粉丝
2
关注
1
看过 TA
112
Java
IP属地:吉林
暂未填写个人简介
私信
关注
2024-04-19 21:04
Java
import java.util.*;public class Main {    public static long ans = 0;    public static List<Long> list = new ArrayList<>();    public static void main(String args[]) {        //4 2        //1 2 3 4        //3 4 2 1        Scanner in = new Scanner(System.in);        long n = in.nextLong();        long k = in.nextLong();        Map<Long, Long> map = new HashMap<>();        List<Long> mark = new ArrayList<>();        for (int i = 0; i < n; i++) {            long x1 = in.nextLong();            mark.add(x1);        }        for (int i = 0; i < n; i++) {            long x2 = in.nextLong();            map.put(mark.get(i), x2);        }        boolean[] visited = new boolean[(int) n];        dfs(k, map, mark, visited, n,-1);        System.out.println(ans);    }
查看3道真题和解析 投递小红书等公司6个岗位
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客企业服务