結果

問題 No.769 UNOシミュレータ
ユーザー tsunabittsunabit
提出日時 2019-07-10 21:10:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 833 ms / 2,000 ms
コード長 2,046 bytes
コンパイル時間 3,100 ms
コンパイル使用メモリ 76,164 KB
実行使用メモリ 82,656 KB
最終ジャッジ日時 2023-08-14 12:21:06
合計ジャッジ時間 13,369 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
56,556 KB
testcase_01 AC 136 ms
57,048 KB
testcase_02 AC 140 ms
56,516 KB
testcase_03 AC 141 ms
56,668 KB
testcase_04 AC 170 ms
60,112 KB
testcase_05 AC 183 ms
58,532 KB
testcase_06 AC 182 ms
56,648 KB
testcase_07 AC 183 ms
56,668 KB
testcase_08 AC 185 ms
58,280 KB
testcase_09 AC 227 ms
61,444 KB
testcase_10 AC 233 ms
61,892 KB
testcase_11 AC 235 ms
60,872 KB
testcase_12 AC 434 ms
65,364 KB
testcase_13 AC 474 ms
65,316 KB
testcase_14 AC 468 ms
66,084 KB
testcase_15 AC 649 ms
74,488 KB
testcase_16 AC 648 ms
74,772 KB
testcase_17 AC 685 ms
76,748 KB
testcase_18 AC 820 ms
82,656 KB
testcase_19 AC 751 ms
80,660 KB
testcase_20 AC 819 ms
82,036 KB
testcase_21 AC 833 ms
80,140 KB
testcase_22 AC 140 ms
56,856 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;
    	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]);
    			
//    			for(int hoge : h) {
//    	    		System.out.println(hoge);
//    	    	}
    			
    			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 + (r * 1), n);
    		}else if("drawtwo".equals(t[i])) {
//    			if(i < m - 2 && "drawtwo".equals(t[i + 1])) {
    			if(i < m - 1 && "drawtwo".equals(t[i + 1])) {
//    				c = c + (r * 1);
    				c = count(c + (r * 1), n);
    				drow++;
    			}else {
    				h[count(c + (r * 1), n)] -= 2 * drow;
//    				c = c + (r * 2);
    				c = count(c + (r * 2), n);
    				drow = 1;
    			}
    		}else if("drawfour".equals(t[i])) {
//    			if(i < m - 2 && "drawfour".equals(t[i + 1])) {
    			if(i < m - 1 && "drawfour".equals(t[i + 1])) {
//    				c = c + (r * 1);
    				c = count(c + (r * 1), n);
    				drow++;
    			}else {
    				h[count(c + (r * 1), n)] -= 4 * drow;
//    				c = c + (r * 2);
    				c = count(c + (r * 2), n);
    				drow = 1;
    			}
    		}else if("skip".equals(t[i])) {
//    			c = c + (r * 2);
    			c = count(c + (r * 2), n);
    		}else if("reverse".equals(t[i])) {
    			r = r * -1;
//    			c = c + (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