为什么我的JAVA代码后两个点会MLE啊,才10^5就MLE了
package lanqiaoRush;
import java.io.*;
import java.util.*;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
static StringTokenizer in;
static String next() {
try {
while (in == null || !in.hasMoreTokens()) {
in = new StringTokenizer(br.readLine());
}
return in.nextToken();
} catch (Exception e) {
return null;
}
}
static int nextInt() {
return Integer.parseInt(next());
}
static int N = 100100;
static int M = 400100;
static int n,m,k,idx;
static int[] h = new int[N];
static int[] ne = new int[M];
static int[] e = new int[M];
static int[] dis = new int[N];
static int[] cnt = new int[N];
static boolean[] st = new boolean[N];
static int inf = (int) 1e9;
static int mod = 100003;
public static void main(String[] args) throws Exception {
n = nextInt();
m = nextInt();
Arrays.fill(h, -1);
for(int i=1;i<=m;i++) {
int a = nextInt();
int b = nextInt();
insert(a,b);
insert(b,a);
}
dij();
for (int i = 1; i <= n; i ++ ) out.printf("%d\n", cnt[i]);
out.close();
}
static void dij() {
Arrays.fill(dis, inf);
dis[1] = 0;
cnt[1] = 1;
Queue<Integer> q = new LinkedList<>();
q.add(1);
while(q.size()>0) {
int k = q.poll();
st[k] = false;
for(int i=h[k];i!=-1;i=ne[i]) {
int j = e[i];
if(dis[j]>dis[k]+1) {
dis[j] = dis[k]+1;
cnt[j] = cnt[k];
if(!st[j]) {
q.add(j);
st[j] = true;
}
}else if(dis[j]==dis[k]+1) {
cnt[j] = (cnt[j]+cnt[k])%mod;
}
}
}
}
static void insert(int a, int b) {
e[idx] = b;
ne[idx] = h[a];
h[a] = idx++;
}
}