/** * @author liuwq * @create 2023-04-01 11:00 */ publicclass 算术教室 { publicstaticvoidmain(String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] s = br.readLine().split(" "); int n = Integer.parseInt(s[0]); int m = Integer.parseInt(s[1]); int x = Integer.parseInt(s[2]); String[] s1 = br.readLine().split(" "); Set<Integer> set = new HashSet<>(); for (int i = 0; i < n; i++){ set.add(x - Integer.parseInt(s1[i])); } String[] s2 = br.readLine().split(" "); for (int i = 0; i < m; i++){ if (set.contains(Integer.parseInt(s2[i]))){ System.out.println("YES"); return; } } System.out.println("NO"); } }
/** * @author liuwq * @create 2023-04-02 14:30 */ publicclasskotori和n皇后 { publicstaticvoidmain(String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int k = Integer.parseInt(br.readLine()); Set<Integer> setX = new HashSet<>(); Set<Integer> setY = new HashSet<>(); Set<Integer> setA = new HashSet<>(); Set<Integer> setS = new HashSet<>(); int flag = 0; for (int i = 1; i <= k; i++){ String[] s = br.readLine().split(" "); int x = Integer.parseInt(s[0]); int y = Integer.parseInt(s[1]); if (flag != 0) continue; if (!setX.add(x) || !setY.add(y) || !setA.add(x+y) || !setS.add(x-y)){ flag = i; //找到第几个皇后是最小不重复的 } } int t = Integer.parseInt(br.readLine()); StringBuilder sb = new StringBuilder(); for (int i = 0; i < t; i++){ int index = Integer.parseInt(br.readLine()); String a = (index < flag || flag == 0) ? "No":"Yes"; sb.append(a); sb.append("\n"); } System.out.println(sb); } }