Advertisement
islomiddin

532_B

Jan 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.37 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         InputStream inputStream = System.in;
  6.         OutputStream outputStream = System.out;
  7.         InputReader in = new InputReader(inputStream);
  8.         PrintWriter out = new PrintWriter(outputStream);
  9.         Solver solver = new Solver();
  10.         solver.solve(in, out);
  11.         out.close();
  12.     }
  13.     static class Solver {
  14.         public void solve(InputReader in, PrintWriter out) {
  15.             int n = in.nextInt();
  16.             int m = in.nextInt();
  17.             int[] a = new int[m];
  18.             for (int i = 0; i < m; ++i) {
  19.                 a[i] = in.nextInt();
  20.             }
  21.             boolean[] chosen = new boolean[n + 1];
  22.             int tot = 0;
  23.             for (int i = 0; i < m; ++i) {
  24.                 if (!chosen[a[i]]) {
  25.                     ++tot;
  26.                     chosen[a[i]] = true;
  27.                 }
  28.                 if (tot == n) {
  29.                     out.print("1");
  30.                     tot = 0;
  31.                     chosen = new boolean[n + 1];
  32.                 } else {
  33.                     out.print("0");
  34.                 }
  35.             }
  36.         }
  37.     }
  38.     static class InputReader {
  39.         public BufferedReader reader;
  40.         public StringTokenizer tokenizer;
  41.         public InputReader(InputStream stream) {
  42.             reader = new BufferedReader(new InputStreamReader(stream), 32768);
  43.             tokenizer = null;
  44.         }
  45.         public String next() {
  46.             while (tokenizer == null || !tokenizer.hasMoreElements()) {
  47.                 try {
  48.                     tokenizer = new StringTokenizer(reader.readLine());
  49.                 } catch (IOException e) {
  50.                     throw new RuntimeException(e);
  51.                 }
  52.             }
  53.             return tokenizer.nextToken();
  54.         }
  55.         public String nextLine() {
  56.             String s = "";
  57.             try {
  58.                 s = reader.readLine();
  59.             } catch (IOException e) {
  60.                 throw new RuntimeException(e);
  61.             }
  62.             return s;
  63.         }
  64.         public int nextInt() {
  65.             return Integer.parseInt(next());
  66.         }
  67.         public long nextLong() {
  68.             return Long.parseLong(next());
  69.         }
  70.         public double nextDouble() {
  71.             return Double.parseDouble(next());
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement