結果
問題 | No.769 UNOシミュレータ |
ユーザー | Pump0129 |
提出日時 | 2018-12-25 08:50:18 |
言語 | Java21 (openjdk 21) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 4,737 bytes |
コンパイル時間 | 2,419 ms |
コンパイル使用メモリ | 78,264 KB |
実行使用メモリ | 58,828 KB |
最終ジャッジ日時 | 2024-05-02 00:17:25 |
合計ジャッジ時間 | 8,572 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 130 ms
53,896 KB |
testcase_01 | AC | 126 ms
53,768 KB |
testcase_02 | AC | 127 ms
53,960 KB |
testcase_03 | AC | 133 ms
56,092 KB |
testcase_04 | AC | 139 ms
54,012 KB |
testcase_05 | AC | 141 ms
54,108 KB |
testcase_06 | AC | 141 ms
54,024 KB |
testcase_07 | AC | 139 ms
53,964 KB |
testcase_08 | AC | 141 ms
54,484 KB |
testcase_09 | AC | 175 ms
54,268 KB |
testcase_10 | AC | 182 ms
54,360 KB |
testcase_11 | AC | 187 ms
54,352 KB |
testcase_12 | AC | 268 ms
57,644 KB |
testcase_13 | AC | 272 ms
57,688 KB |
testcase_14 | AC | 272 ms
57,368 KB |
testcase_15 | AC | 324 ms
58,224 KB |
testcase_16 | AC | 315 ms
58,736 KB |
testcase_17 | AC | 305 ms
57,760 KB |
testcase_18 | AC | 339 ms
58,276 KB |
testcase_19 | AC | 345 ms
58,348 KB |
testcase_20 | AC | 354 ms
58,332 KB |
testcase_21 | AC | 348 ms
58,828 KB |
testcase_22 | WA | - |
ソースコード
package net.ipipip0129.yukicoder.No769; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class No769 { int ans = 0; int person_number; int log_number; BufferedReader reader; No769() throws IOException { reader = new BufferedReader(new InputStreamReader(System.in)); String[] split_str = reader.readLine().split(" "); person_number = Integer.parseInt(split_str[0]); log_number = Integer.parseInt(split_str[1]); int[] ans_array = analyze(); System.out.printf("%d %d\n", ans_array[0], ans_array[1]); } private int[] analyze() throws IOException { int[] persons_card = new int[person_number]; int turn_number = 0; int drawtwo_acc = 0; int drawfour_acc = 0; boolean is_reverse = false; for (int i = 0; i < log_number; i++) { switch (reader.readLine()) { case "number": if (0 < drawtwo_acc) { persons_card[turn_number] -= 2 * drawtwo_acc; drawtwo_acc = 0; turn_number = getNextTurn(turn_number, is_reverse); } else if (0 < drawfour_acc) { persons_card[turn_number] -= 4 * drawfour_acc; drawfour_acc = 0; turn_number = getNextTurn(turn_number, is_reverse); } persons_card[turn_number] += 1; break; case "drawtwo": if (0 < drawfour_acc) { persons_card[turn_number] -= 4 * drawfour_acc; drawfour_acc = 0; turn_number = getNextTurn(turn_number, is_reverse); } drawtwo_acc += 1; persons_card[turn_number] += 1; break; case "drawfour": if (0 < drawtwo_acc) { persons_card[turn_number] -= 2 * drawtwo_acc; drawtwo_acc = 0; turn_number = getNextTurn(turn_number, is_reverse); } drawfour_acc += 1; persons_card[turn_number] += 1; break; case "skip": if (0 < drawtwo_acc) { persons_card[turn_number] -= 2 * drawtwo_acc; drawtwo_acc = 0; turn_number = getNextTurn(turn_number, is_reverse); } else if (0 < drawfour_acc) { persons_card[turn_number] -= 4 * drawfour_acc; drawfour_acc = 0; turn_number = getNextTurn(turn_number, is_reverse); } persons_card[turn_number] += 1; turn_number = getNextTurn(turn_number, is_reverse); break; case "reverse": if (0 < drawtwo_acc) { persons_card[turn_number] -= 2 * drawtwo_acc; drawtwo_acc = 0; turn_number = getNextTurn(turn_number, is_reverse); } else if (0 < drawfour_acc) { persons_card[turn_number] -= 4 * drawfour_acc; drawfour_acc = 0; turn_number = getNextTurn(turn_number, is_reverse); } is_reverse = !is_reverse; persons_card[turn_number] += 1; break; } turn_number = getNextTurn(turn_number, is_reverse); } is_reverse = !is_reverse; turn_number = getNextTurn(turn_number, is_reverse); return new int[] {turn_number + 1, persons_card[turn_number]}; } private int getNextTurn(int turn, boolean reverse) { if (reverse) { if (turn == 0) { return this.person_number - 1; } else { return turn - 1; } } else { if (turn == this.person_number - 1) { return 0; } else { return turn + 1; } } } public int getAns() { return ans; } } public class Main { public static void main(String[] args) { try { No769 ques = new No769(); } catch (IOException e) { e.printStackTrace(); } } }