結果

問題 No.1405 ジグザグロボット
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-02-19 22:55:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 8,240 bytes
コンパイル時間 2,542 ms
コンパイル使用メモリ 80,424 KB
実行使用メモリ 53,724 KB
最終ジャッジ日時 2023-10-17 00:03:23
合計ジャッジ時間 13,229 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 55 ms
53,704 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 53 ms
53,712 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 55 ms
53,704 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 54 ms
53,708 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 55 ms
53,700 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.NoSuchElementException;

public class Main {

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

	public Main() {

		final InputChecker ic = new InputChecker(System.in);
		final java.io.PrintWriter out = new java.io.PrintWriter(System.out);
		solve(ic, out);
		out.flush();
	}

	public void solve(final InputChecker ic, final java.io.PrintWriter out) {
		final int N = ic.nextInt(1, 2021);
		ic.nextChar(' ');
		final int X = ic.nextInt(0, N);
		ic.nextChar(' ');
		final int Y = ic.nextInt(0, N);
		ic.readNewLine();
		final CharSet charSet = new CharSet();
		charSet.add('L', 'S', 'R');
		final char[] S = ic.next(charSet).toCharArray();
		if (S.length != N)
			throw new AssertionError();
		ic.readNewLine();
		ic.checkEOF();
		out.println(-1);
	}

	public static class CharSet {
		private final BitSet set = new BitSet(256);

		public void add(final char... c) {
			for (final char i : c)
				set.set(i);
		}

		public void add(final CharSet... s) {
			for (final CharSet i : s)
				set.or(i.set);
		}

		public boolean contains(final char... c) {
			for (final char i : c)
				if (!set.get(i))
					return false;
			return true;
		}

		public boolean contains(final String s) {
			return contains(s.toCharArray());
		}

		private static final class Chars extends CharSet {
			public Chars(final char... c) {
				super.add(c);
			}

			public Chars(final CharSet... s) {
				super.add(s);
			}

			@Override
			public void add(final char... c) {
				throw new UnsupportedOperationException();
			}

			@Override
			public void add(final CharSet... s) {
				throw new UnsupportedOperationException();
			}
		}

		public static final CharSet NUMBER = new Chars('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
		public static final CharSet LOWER = new Chars('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
				'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
		public static final CharSet UPPER = new Chars('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
				'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
		public static final CharSet ALPHABET = new Chars(LOWER, UPPER);

	}

	public static class InputChecker {
		private InputStream in;
		private final byte[] buffer = new byte[1024];
		private final byte[] undo = new byte[1024];
		private int undoSize = 0;
		private int read = 0;
		private int length = 0;

		public InputChecker(final InputStream in) {
			this.in = in;
		}

		public final void setInputStream(final InputStream in) {
			this.in = in;
		}

		public final void setInputStream(final File in) {
			try {
				this.in = new FileInputStream(in);
			} catch (final FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		private boolean hasNextByte() {
			if (undoSize > 0)
				return true;
			if (read < length)
				return true;
			read = 0;
			try {
				length = in.read(buffer);
			} catch (final IOException e) {
				e.printStackTrace();
			}
			return length > 0;
		}

		private byte readByte() {
			if (hasNextByte())
				return undoSize > 0 ? undo[--undoSize] : buffer[read++];
			throw new NoSuchElementException();
		}

		private void undo(final byte b) {
			undo[undoSize++] = b;
		}

		private void undo(final char c) {
			if ((c & 0xFF80) == 0) {
				undo((byte) c);
				return;
			}
			undo((byte) (c & 0x3F | 0x80));
			if ((c & 0xF800) == 0)
				undo((byte) (c >> 6 & 0x1F | 0xC0));
			else {
				undo((byte) (c >> 6 & 0x3F | 0x80));
				undo((byte) (c >> 12 | 0xE0));
			}
		}

		public final boolean hasNext() {
			return hasNextByte();
		}

		public final char nextChar() {
			final byte b = readByte();
			if ((b & 0x80) == 0)
				return (char) b;
			if ((b & 0x20) == 0)
				return (char) ((b & 0x1F) << 6 | readByte() & 0x3F);
			return (char) ((b & 0xF) << 12 | (readByte() & 0x3F) << 6 | readByte() & 0x3F);
		}

		public final char nextChar(final char estimate) {
			final char c = nextChar();
			if (estimate == c)
				return estimate;
			undo(c);
			throw new AssertionError();
		}

		public final char nextChar(final CharSet estimate) {
			final char c = nextChar();
			if (estimate.contains(c))
				return c;
			undo(c);
			throw new AssertionError();
		}

		public final void readNewLine() {
			char c = nextChar();
			if (c == '\r') {
				c = nextChar();
				if (c != '\n')
					undo(c);
				return;
			} else if (c == '\n')
				return;
			undo(c);
			throw new AssertionError();
		}

		public final void checkEOF() {
			if (hasNextByte())
				throw new AssertionError();
		}

		public final String next(final CharSet contains) {
			final StringBuilder sb = new StringBuilder();
			try {
				do {
					final char c = nextChar();
					if (!contains.contains(c)) {
						undo(c);
						return sb.toString();
					}
					sb.append(c);
				} while (true);
			} catch (final NoSuchElementException e) {
				if (sb.length() <= 0)
					throw new AssertionError();
				return sb.toString();
			}
		}

		public final int nextInt() {
			byte b = readByte();
			int n = 0;
			if (b == '-') {
				if (!isNumber(b = readByte())) {
					undo(b);
					throw new NumberFormatException();
				}
				try {
					if (b == '0') {
						if (!isNumber(b = readByte())) {
							undo(b);
							return 0;
						}
						throw new NumberFormatException();
					}
					do
						n = Math.addExact(Math.multiplyExact(n, 10), '0' - b);
					while (isNumber(b = readByte()));
					undo(b);
				} catch (final NoSuchElementException e) {
				}
				return n;
			}
			if (!isNumber(b)) {
				undo(b);
				throw new NumberFormatException();
			}
			try {
				if (b == '0') {
					if (!isNumber(b = readByte())) {
						undo(b);
						return 0;
					}
					throw new NumberFormatException();
				}
				do
					n = Math.addExact(Math.multiplyExact(n, 10), b - '0');
				while (isNumber(b = readByte()));
				undo(b);
			} catch (final NoSuchElementException e) {
			}
			return n;
		}

		public final int nextInt(final int min, final int max) {
			final int n = nextInt();
			if (min <= n && n <= max)
				return n;
			throw new NumberFormatException();
		}

		private static boolean isNumber(final byte c) {
			return '0' <= c && c <= '9';
		}

		public final long nextLong() {
			byte b = readByte();
			long n = 0;
			if (b == '-') {
				if (!isNumber(b = readByte())) {
					undo(b);
					throw new NumberFormatException();
				}
				try {
					if (b == '0') {
						if (!isNumber(b = readByte())) {
							undo(b);
							return 0;
						}
						throw new NumberFormatException();
					}
					do
						n = Math.addExact(Math.multiplyExact(n, 10), '0' - b);
					while (isNumber(b = readByte()));
					undo(b);
				} catch (final NoSuchElementException e) {
				}
				return n;
			}
			if (!isNumber(b)) {
				undo(b);
				throw new NumberFormatException();
			}
			try {
				if (b == '0') {
					if (!isNumber(b = readByte())) {
						undo(b);
						return 0;
					}
					throw new NumberFormatException();
				}
				do
					n = Math.addExact(Math.multiplyExact(n, 10), b - '0');
				while (isNumber(b = readByte()));
				undo(b);
			} catch (final NoSuchElementException e) {
			}
			return n;
		}

		public final long nextLong(final long min, final long max) {
			final long n = nextLong();
			if (min <= n && n <= max)
				return n;
			throw new NumberFormatException();
		}

		public final double nextDouble() {
			final StringBuilder sb = new StringBuilder();
			byte b = readByte();
			if (b == '-') {
				sb.append(b);
				b = readByte();
			}
			if (b == '0') {
				sb.append(b);
				b = readByte();
			} else
				while (isNumber(b)) {
					sb.append(b);
					b = readByte();
				}
			if (b == '.') {
				sb.append(b);
				b = readByte();
				while (isNumber(b)) {
					sb.append(b);
					b = readByte();
				}
			}
			if (b == 'e' || b == 'E') {
				sb.append(b);
				b = readByte();
				if (b == '-' || b == '+') {
					sb.append(b);
					b = readByte();
				}
				while (isNumber(b)) {
					sb.append(b);
					b = readByte();
				}
			}
			undo(b);
			return Double.parseDouble(sb.toString());
		}
	}
}
0