結果

問題 No.769 UNOシミュレータ
ユーザー 37zigen37zigen
提出日時 2020-03-22 03:56:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,465 bytes
コンパイル時間 4,334 ms
コンパイル使用メモリ 76,352 KB
実行使用メモリ 82,708 KB
最終ジャッジ日時 2023-08-14 12:30:18
合計ジャッジ時間 15,401 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
56,688 KB
testcase_01 AC 154 ms
56,884 KB
testcase_02 AC 163 ms
56,740 KB
testcase_03 AC 161 ms
56,840 KB
testcase_04 WA -
testcase_05 AC 214 ms
57,276 KB
testcase_06 AC 204 ms
57,020 KB
testcase_07 AC 213 ms
58,384 KB
testcase_08 AC 210 ms
58,776 KB
testcase_09 WA -
testcase_10 AC 253 ms
61,296 KB
testcase_11 AC 254 ms
62,068 KB
testcase_12 WA -
testcase_13 AC 551 ms
66,484 KB
testcase_14 AC 555 ms
66,028 KB
testcase_15 WA -
testcase_16 AC 637 ms
74,356 KB
testcase_17 AC 738 ms
75,252 KB
testcase_18 AC 805 ms
80,768 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 905 ms
82,708 KB
testcase_22 AC 152 ms
56,580 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