結果

問題 No.769 UNOシミュレータ
ユーザー tsunabittsunabit
提出日時 2019-07-10 00:00:17
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,664 bytes
コンパイル時間 5,782 ms
コンパイル使用メモリ 76,316 KB
実行使用メモリ 83,364 KB
最終ジャッジ日時 2023-08-14 12:20:39
合計ジャッジ時間 14,700 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
56,484 KB
testcase_01 AC 138 ms
56,964 KB
testcase_02 AC 141 ms
56,672 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 188 ms
58,340 KB
testcase_06 AC 187 ms
56,868 KB
testcase_07 AC 180 ms
57,328 KB
testcase_08 AC 181 ms
57,104 KB
testcase_09 WA -
testcase_10 AC 237 ms
61,464 KB
testcase_11 AC 220 ms
61,484 KB
testcase_12 WA -
testcase_13 AC 528 ms
67,356 KB
testcase_14 AC 428 ms
65,640 KB
testcase_15 WA -
testcase_16 AC 682 ms
76,116 KB
testcase_17 WA -
testcase_18 AC 824 ms
82,288 KB
testcase_19 AC 697 ms
81,236 KB
testcase_20 WA -
testcase_21 AC 838 ms
81,940 KB
testcase_22 AC 138 ms
56,932 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);
    	// "number", "drawtwo", "drawfour", "skip", "reverse"
    	int n = sc.nextInt(), m = sc.nextInt();
    	int[] h = new int[n];
    	String[] t = new String[m];
    	int c = 0;
    	int r = 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;
    		}
    		
//    		System.out.println("i = " + i + " c = " + (c + 1) + " maisu = " + h[c] + " fuda = " + t[i]);
    		
    		if("number".equals(t[i])) {
    			c = c + (r * 1);
    			c = count(c, n);
    		}else if("drawtwo".equals(t[i])) {
    			if(i < m - 2 && "drawtwo".equals(t[i + 1])) {
    				c = c + (r * 1);
    				c = count(c, n);
    			}else {
    				h[count(c + (r * 1), n)] -= 2;
    				c = c + (r * 2);
    				c = count(c, n);
    			}
    		}else if("drawfour".equals(t[i])) {
    			if(i < m - 2 && "drawfour".equals(t[i + 1])) {
    				c = c + (r * 1);
    				c = count(c, n);
    			}else {
    				h[count(c + (r * 1), n)] -= 4;
    				c = c + (r * 2);
    				c = count(c, n);
    			}
    		}else if("skip".equals(t[i])) {
    			c = c + (r * 2);
    			c = count(c, n);
    		}else if("reverse".equals(t[i])) {
    			r = r * -1;
    			c = c + (r * 1);
    			c = count(c, 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