2 条题解
-
0
-
0
JAVA ac代码: 送分题,掌握set的运用
import java.util.*; import java.util.StringTokenizer; import java.io.*; public class Main { public static void main(String[] args) { int q=in.nextInt(); Set<Integer> set=new HashSet<>(); while(q-->0){ String op=in.next(); int x=in.nextInt(); if(op.equals("I")){ set.add(x); }else{ if(set.contains(x)) out.println("Yes"); else out.println("No"); } } out.close(); } static FastReader in=new FastReader(); static PrintWriter out=new PrintWriter(System.out); static class FastReader{ static BufferedReader br; static StringTokenizer st; FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); } String next() { String str=""; while(st==null||!st.hasMoreElements()) { try { str=br.readLine(); }catch(IOException e) { throw new RuntimeException(e); } st=new StringTokenizer(str); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } } }
- 1
信息
- ID
- 44
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 3
- 标签
- 递交数
- 36
- 已通过
- 18
- 上传者