AcWing 4454. 未初始化警告 Set java
原题链接
简单
作者:
IF_3
,
2023-01-09 22:23:52
,
所有人可见
,
阅读 144
import java.util.*;
import java.io.*;
class Main{
static Set<Integer> set = new HashSet<>();
static int n, k;
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] strs = br.readLine().split(" ");
n = Integer.parseInt(strs[0]);
k = Integer.parseInt(strs[1]);
int res = 0;
set.add(0);
for (int i = 0; i < k; i ++){
strs = br.readLine().split(" ");
int l = Integer.parseInt(strs[0]);
int r = Integer.parseInt(strs[1]);
if (set.contains(r)) res ++;
set.add(l);
}
System.out.println(k - res);
br.close();
}
}