Submission #371132


Source Code Expand

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.InputMismatchException;

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
		
	public void run() {
		String s = in.nextLine();
		String[] words = s.split(" ");
		
		StringBuilder res = new StringBuilder();
		int not_cnt = 0;
		for (String w : words) {
			if (w.matches("not")) 
				not_cnt++;
			else {
				if (not_cnt % 2 != 0) {
					for (int i = 0; i < not_cnt; i++) {
						res.append("not ");
					}
				}
				not_cnt = 0;
				res.append(w + " ");
			}
		}
		for (int i = 0; i < not_cnt; i++) {
			res.append("not ");
		}
		String ans = res.toString();
		System.out.println(ans.substring(0, ans.length() - 1));
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

		int[][] nextIntMap(int n, int m) {
			int[][] map = new int[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextIntArray(m);
			}
			return map;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

		long[][] nextLongMap(int n, int m) {
			long[][] map = new long[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextLongArray(m);
			}
			return map;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		double[][] nextDoubleMap(int n, int m) {
			double[][] map = new double[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextDoubleArray(m);
			}
			return map;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Submission Info

Submission Time
Task A - 二重否定除去法則
User hiro116s
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 4061 Byte
Status WA
Exec Time 357 ms
Memory 29156 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 14
WA × 5
Set Name Test Cases
All scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt
Case Name Status Exec Time Memory
scrambled_00.txt AC 315 ms 27568 KB
scrambled_01.txt AC 321 ms 27492 KB
scrambled_02.txt AC 335 ms 27396 KB
scrambled_03.txt WA 325 ms 27368 KB
scrambled_04.txt WA 321 ms 27460 KB
scrambled_05.txt WA 357 ms 29020 KB
scrambled_06.txt AC 334 ms 29156 KB
scrambled_07.txt AC 343 ms 28832 KB
scrambled_08.txt WA 349 ms 28896 KB
scrambled_09.txt AC 337 ms 27776 KB
scrambled_10.txt AC 336 ms 27720 KB
scrambled_11.txt AC 336 ms 27976 KB
scrambled_12.txt AC 345 ms 28268 KB
scrambled_13.txt AC 355 ms 28316 KB
scrambled_14.txt WA 348 ms 28424 KB
scrambled_15.txt AC 329 ms 28416 KB
scrambled_16.txt AC 337 ms 28428 KB
scrambled_17.txt AC 336 ms 28488 KB
scrambled_18.txt AC 343 ms 28444 KB