結果

問題 No.715 集合と二人ゲーム
ユーザー 37zigen37zigen
提出日時 2018-07-15 06:07:52
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,914 bytes
コンパイル時間 2,274 ms
コンパイル使用メモリ 76,128 KB
実行使用メモリ 60,184 KB
最終ジャッジ日時 2023-08-03 13:28:34
合計ジャッジ時間 12,338 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
33,952 KB
testcase_01 AC 52 ms
35,264 KB
testcase_02 WA -
testcase_03 AC 62 ms
35,696 KB
testcase_04 WA -
testcase_05 AC 68 ms
35,800 KB
testcase_06 WA -
testcase_07 AC 72 ms
35,632 KB
testcase_08 WA -
testcase_09 AC 76 ms
35,660 KB
testcase_10 WA -
testcase_11 AC 77 ms
35,860 KB
testcase_12 AC 77 ms
35,848 KB
testcase_13 AC 78 ms
35,800 KB
testcase_14 WA -
testcase_15 AC 81 ms
35,752 KB
testcase_16 WA -
testcase_17 AC 77 ms
35,816 KB
testcase_18 WA -
testcase_19 AC 86 ms
35,812 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 81 ms
35,904 KB
testcase_24 AC 84 ms
36,320 KB
testcase_25 AC 88 ms
36,072 KB
testcase_26 WA -
testcase_27 AC 87 ms
36,388 KB
testcase_28 AC 86 ms
36,348 KB
testcase_29 AC 88 ms
36,072 KB
testcase_30 AC 103 ms
36,528 KB
testcase_31 AC 99 ms
36,952 KB
testcase_32 AC 96 ms
36,576 KB
testcase_33 AC 98 ms
37,000 KB
testcase_34 AC 98 ms
36,424 KB
testcase_35 AC 38 ms
33,976 KB
testcase_36 AC 38 ms
33,952 KB
testcase_37 AC 38 ms
33,908 KB
testcase_38 AC 38 ms
33,840 KB
testcase_39 AC 37 ms
34,248 KB
testcase_40 WA -
testcase_41 AC 45 ms
34,156 KB
testcase_42 AC 44 ms
34,320 KB
testcase_43 AC 44 ms
34,188 KB
testcase_44 AC 44 ms
34,252 KB
testcase_45 AC 43 ms
34,096 KB
testcase_46 AC 44 ms
34,320 KB
testcase_47 AC 44 ms
34,256 KB
testcase_48 AC 43 ms
34,272 KB
testcase_49 AC 43 ms
34,268 KB
testcase_50 WA -
testcase_51 AC 195 ms
41,088 KB
testcase_52 WA -
testcase_53 AC 222 ms
39,732 KB
testcase_54 AC 224 ms
39,920 KB
testcase_55 AC 201 ms
41,176 KB
testcase_56 WA -
testcase_57 AC 209 ms
39,612 KB
testcase_58 WA -
testcase_59 AC 184 ms
40,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	int[] gr = new int[100];

	int calc(int p) {
		long mask = 0;
		for (int i = 1; i <= p; ++i) {
			int L = Math.max(0, i - 2), R = Math.max(0, p - i - 1);
			mask |= 1L << (gr[L] ^ gr[R]);
		}
		while ((mask & 1L << gr[p]) > 0) {
			++gr[p];
		}
		return gr[p];
	}

	public void run() {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		gr[1] = gr[2] = 1;

		for (int i = 3; i < 100; ++i) {
			calc(i);
		}
		int mod = 34;

		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int g = 0;
		for (int i = 0; i < n; ++i) {
			int j = i;
			while (j + 1 < n && (a[j] == a[j + 1] || a[j] + 1 == a[j + 1]))
				++j;
			g ^= gr[(a[j] - a[i] + 1) % mod];
			i = j;
		}
		pw.println(g == 0 ? "Second" : "First");
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

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

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0