結果

問題 No.769 UNOシミュレータ
ユーザー 37zigen37zigen
提出日時 2020-03-22 04:08:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 901 ms / 2,000 ms
コード長 1,465 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 76,288 KB
実行使用メモリ 82,280 KB
最終ジャッジ日時 2023-08-14 12:30:38
合計ジャッジ時間 13,170 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
57,004 KB
testcase_01 AC 149 ms
57,044 KB
testcase_02 AC 156 ms
56,944 KB
testcase_03 AC 159 ms
56,816 KB
testcase_04 AC 198 ms
58,992 KB
testcase_05 AC 200 ms
56,968 KB
testcase_06 AC 200 ms
58,888 KB
testcase_07 AC 201 ms
58,764 KB
testcase_08 AC 203 ms
58,408 KB
testcase_09 AC 250 ms
61,644 KB
testcase_10 AC 249 ms
61,652 KB
testcase_11 AC 241 ms
61,180 KB
testcase_12 AC 474 ms
66,352 KB
testcase_13 AC 554 ms
66,532 KB
testcase_14 AC 476 ms
66,280 KB
testcase_15 AC 641 ms
74,400 KB
testcase_16 AC 733 ms
76,916 KB
testcase_17 AC 729 ms
76,676 KB
testcase_18 AC 901 ms
82,280 KB
testcase_19 AC 890 ms
81,928 KB
testcase_20 AC 791 ms
80,872 KB
testcase_21 AC 777 ms
80,492 KB
testcase_22 AC 151 ms
56,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long t = System.currentTimeMillis();
		new Main().run();
		System.err.println(System.currentTimeMillis() - t);
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[] pay=new int[N];
		String[] l=new String[M];
		int p=0,dir=1;
		for(int i=0;i<M;++i)l[i]=sc.next();
		for(int i=0;i<M;++i) {
			if(l[i].equals("number")) {
				pay[p]++;
				if(i!=M-1)p=(p+dir+N)%N;
			}else if(l[i].equals("skip")) {
				pay[p]++;
				if(i!=M-1)p=(p+2*dir+N)%N;
			}else if(l[i].equals("reverse")) {
				pay[p]++;
				dir*=-1;
				if(i!=M-1)p=(p+dir+N)%N;
			}else if(l[i].equals("drawtwo")) {
				int j=i;
				while(j+1<l.length&&l[i].equals(l[j+1])) {
					++j;
				}
				for(int k=i;k<=j;++k) {
					pay[p]++;
					p=(p+dir+N)%N;
				}
				pay[p]-=(j-i+1)*2;
				i=j;
				if(i!=M-1)p=(p+dir+N)%N;
				else p=(p-dir+N)%N;
			}else if(l[i].equals("drawfour")) {
				int j=i;
				while(j+1<l.length&&l[i].equals(l[j+1])) {
					++j;
				}
				for(int k=i;k<=j;++k) {
					pay[p]++;
					p=(p+dir+N)%N;
				}
				pay[p]-=(j-i+1)*4;
				i=j;
				if(i!=M-1)p=(p+dir+N)%N;			
				else p=(p-dir+N)%N;
			}
		}
		System.out.println((p+1)+" "+pay[p]);
	}


	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0