結果

問題 No.769 UNOシミュレータ
ユーザー face4face4
提出日時 2018-12-01 18:28:08
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,971 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 78,708 KB
実行使用メモリ 57,944 KB
最終ジャッジ日時 2024-05-02 00:06:50
合計ジャッジ時間 6,437 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
51,332 KB
testcase_01 AC 80 ms
51,332 KB
testcase_02 AC 71 ms
51,184 KB
testcase_03 AC 80 ms
51,096 KB
testcase_04 AC 84 ms
51,352 KB
testcase_05 AC 78 ms
51,220 KB
testcase_06 AC 77 ms
51,420 KB
testcase_07 AC 84 ms
51,140 KB
testcase_08 AC 83 ms
50,924 KB
testcase_09 AC 129 ms
53,596 KB
testcase_10 AC 132 ms
53,088 KB
testcase_11 AC 134 ms
53,648 KB
testcase_12 AC 197 ms
57,340 KB
testcase_13 AC 180 ms
57,340 KB
testcase_14 AC 194 ms
57,212 KB
testcase_15 AC 233 ms
57,796 KB
testcase_16 AC 230 ms
57,944 KB
testcase_17 AC 234 ms
57,576 KB
testcase_18 AC 264 ms
56,972 KB
testcase_19 AC 264 ms
57,424 KB
testcase_20 AC 259 ms
56,872 KB
testcase_21 AC 254 ms
57,400 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class A{
    A() {}

    int put[], draw[];
    int n, m, turn, dir;
    
    void proceed(){
        turn = (turn+dir+n)%n;
    }

    void solve() throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line[] = br.readLine().split(" ");
        n = Integer.parseInt(line[0]);
        m = Integer.parseInt(line[1]);

        put = new int[n];
        draw = new int[n];
        int d2 = 0;
        int d4 = 0;
        turn = 0;
        dir = 1;

        String card;
        while(m-- > 0){
            card = br.readLine();

            if(d2 > 0 && card.equals("drawtwo")){
                d2++;
                put[turn]++;
                proceed();
                continue;
            }
    
            if(d4 > 0 && card.equals("drawfour")){
                d4++;
                put[turn]++;
                proceed();
                continue;
            }
    
            if(d2 > 0){
                draw[turn] += 2*d2;
                d2 = 0;
                proceed();
            }
            
            if(d4 > 0){
                draw[turn] += 4*d4;
                d4 = 0;
                proceed();
            }
    
            put[turn]++;
    
            if(card.equals("drawtwo")){
                d2++;
            }else if(card.equals("drawfour")){
                d4++;
            }else if(card.equals("skip")){
                proceed();
            }else if(card.equals("reverse")){
                dir *= -1;
            }else if(card.equals("number")){
                // do nothing.
            }

            proceed();
        }

        turn = (turn-dir+n)%n;

        System.out.println((turn+1) + " " + (put[turn]-draw[turn]));
    }
}

class Main{
    public static void main(String[] args) throws IOException{
        new A().solve();
    }
}
0