Submission #2972169


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), m = in.nextInt();
			int[] a = in.nextIntArray(m);

			Set<Integer> set = new HashSet<>();
			for (int i = m-1; i >= 0; i--) {
				if (set.contains(a[i])) {
					continue;
				}
				out.println(a[i]);
				set.add(a[i]);
			}

			for (int i = 1; i <= n; i++) {
				if (set.contains(i)) {
					continue;
				}
				out.println(i);
				set.add(i);
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}

Submission Info

Submission Time
Task A - 掲示板
User tutuz
Language Java8 (OpenJDK 1.8.0)
Score 100
Code Size 2812 Byte
Status AC
Exec Time 301 ms
Memory 45132 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 30 / 30 70 / 70
Status
AC × 3
AC × 14
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, subtask1_00.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt
Subtask2 sample_01.txt, sample_02.txt, sample_03.txt, subtask1_00.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask2_00.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt
Case Name Status Exec Time Memory
sample_01.txt AC 73 ms 20948 KB
sample_02.txt AC 73 ms 19156 KB
sample_03.txt AC 72 ms 18388 KB
subtask1_00.txt AC 73 ms 19540 KB
subtask1_01.txt AC 74 ms 20948 KB
subtask1_02.txt AC 72 ms 19028 KB
subtask1_03.txt AC 72 ms 19540 KB
subtask1_04.txt AC 72 ms 19540 KB
subtask1_05.txt AC 73 ms 20692 KB
subtask1_06.txt AC 72 ms 18516 KB
subtask1_07.txt AC 72 ms 21460 KB
subtask1_08.txt AC 71 ms 20052 KB
subtask1_09.txt AC 74 ms 20052 KB
subtask1_10.txt AC 73 ms 20820 KB
subtask2_00.txt AC 252 ms 42928 KB
subtask2_01.txt AC 132 ms 22484 KB
subtask2_02.txt AC 264 ms 43344 KB
subtask2_03.txt AC 150 ms 27724 KB
subtask2_04.txt AC 182 ms 32976 KB
subtask2_05.txt AC 286 ms 44844 KB
subtask2_06.txt AC 250 ms 41640 KB
subtask2_07.txt AC 192 ms 34776 KB
subtask2_08.txt AC 222 ms 35324 KB
subtask2_09.txt AC 154 ms 29780 KB
subtask2_10.txt AC 301 ms 42004 KB
subtask2_11.txt AC 300 ms 43500 KB
subtask2_12.txt AC 281 ms 42496 KB
subtask2_13.txt AC 295 ms 44732 KB
subtask2_14.txt AC 285 ms 45132 KB
subtask2_15.txt AC 278 ms 38648 KB