結果

問題 No.769 UNOシミュレータ
ユーザー tsunabittsunabit
提出日時 2019-07-10 21:12:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 916 ms / 2,000 ms
コード長 1,458 bytes
コンパイル時間 3,459 ms
コンパイル使用メモリ 75,848 KB
実行使用メモリ 82,440 KB
最終ジャッジ日時 2023-08-14 12:22:16
合計ジャッジ時間 14,642 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
56,764 KB
testcase_01 AC 146 ms
56,312 KB
testcase_02 AC 153 ms
56,968 KB
testcase_03 AC 155 ms
56,572 KB
testcase_04 AC 202 ms
59,360 KB
testcase_05 AC 202 ms
57,656 KB
testcase_06 AC 201 ms
57,944 KB
testcase_07 AC 205 ms
58,904 KB
testcase_08 AC 201 ms
58,468 KB
testcase_09 AC 256 ms
61,596 KB
testcase_10 AC 251 ms
61,360 KB
testcase_11 AC 246 ms
61,416 KB
testcase_12 AC 568 ms
66,220 KB
testcase_13 AC 520 ms
65,824 KB
testcase_14 AC 555 ms
65,856 KB
testcase_15 AC 635 ms
75,260 KB
testcase_16 AC 706 ms
75,144 KB
testcase_17 AC 741 ms
77,144 KB
testcase_18 AC 804 ms
81,164 KB
testcase_19 AC 905 ms
82,440 KB
testcase_20 AC 911 ms
82,412 KB
testcase_21 AC 916 ms
82,088 KB
testcase_22 AC 149 ms
57,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No769 {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt(), m = sc.nextInt();
    	int[] h = new int[n];
    	String[] t = new String[m];
    	int c = 0;
    	int r = 1;
    	int drow = 1;
    	
    	for(int i = 0; i < m ; i++) {
    		t[i] = sc.next();
    	}
    	for(int i = 0; i < m; i++) {
    		h[c] += 1;
    		if(i == m - 1) {
    			System.out.println((c + 1) + " " + h[c]);
    			return;
    		}
    		if("number".equals(t[i])) {
    			c = count(c + (r * 1), n);
    		}else if("drawtwo".equals(t[i])) {
    			if(i < m - 1 && "drawtwo".equals(t[i + 1])) {
    				c = count(c + (r * 1), n);
    				drow++;
    			}else {
    				h[count(c + (r * 1), n)] -= 2 * drow;
    				c = count(c + (r * 2), n);
    				drow = 1;
    			}
    		}else if("drawfour".equals(t[i])) {
    			if(i < m - 1 && "drawfour".equals(t[i + 1])) {
    				c = count(c + (r * 1), n);
    				drow++;
    			}else {
    				h[count(c + (r * 1), n)] -= 4 * drow;
    				c = count(c + (r * 2), n);
    				drow = 1;
    			}
    		}else if("skip".equals(t[i])) {
    			c = count(c + (r * 2), n);
    		}else if("reverse".equals(t[i])) {
    			r = r * -1;
    			c = count(c + (r * 1), n);
    		}
    	}
    }
    public static int count(int c, int n) {
    	if(c > n -1) c = c - n;
		else if(c < 0) c = c + n;
    	return c;
    }
}
0