全部评论
我最短路过了70
分享
一直说我的复杂度太高,python本地编译器 1秒内出结果啊 我测试时间来着
分享
跳跃递推和射球门,就是ac不了
分享
蹲一下
分享
就是把路径先保存好,从起始点1开始bfs,如果一次直达直接返回
分享
直接保存出发点能到的所有地点和终点能到达的所有地点,有重合就能到,没有就不能
分享
我用的动态规划,a了
分享
哪那么复杂。。。。。。。
分享
参考数据结构图 那章,求两节点最短路径,用的动态规划
分享
射球门0.36,跳跃递推一次超时一次超内存哭了
分享
两个hashset就搞定了。。
分享
蹲一个ac
分享
哪位大佬看看这样行不行 import java.util.HashSet;
import java.util.Scanner;
public class main3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
int [] res = new int[T];
for(int k=0;k<T;++k){
int n = sc.nextInt();
int m = sc.nextInt();
HashSet<Integer> set1 = new HashSet<>();
HashSet<Integer> set2 = new HashSet<>();
for(int i=0;i<m;++i){
int x = sc.nextInt();
int y = sc.nextInt();
if(x==1 || y==1){
set1.add(x+y-1);
}
else if(x==n || y==n){
set2.add(x+y-n);
}
}
for(int c:set1){
if(set2.contains(c)){
res[k]=1;
}
}
}
for(int c:res){
if(c==1){
System.out.println("POSSIBLE");
}
else {
System.out.println("IMPOSSIBLE");
}
}
}
}
分享
相关推荐
09-08 19:22
University of Glasgow 金融学类 点赞 评论 收藏
转发
点赞 评论 收藏
转发
点赞 评论 收藏
转发