結果
問題 | No.351 市松スライドパズル |
ユーザー | 37zigen |
提出日時 | 2016-03-12 04:28:58 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 764 ms / 2,000 ms |
コード長 | 1,915 bytes |
コンパイル時間 | 3,911 ms |
コンパイル使用メモリ | 78,760 KB |
実行使用メモリ | 69,972 KB |
最終ジャッジ日時 | 2023-10-25 07:28:51 |
合計ジャッジ時間 | 13,029 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 702 ms
69,000 KB |
testcase_01 | AC | 56 ms
53,520 KB |
testcase_02 | AC | 57 ms
53,532 KB |
testcase_03 | AC | 56 ms
53,524 KB |
testcase_04 | AC | 57 ms
53,528 KB |
testcase_05 | AC | 58 ms
53,520 KB |
testcase_06 | AC | 57 ms
53,520 KB |
testcase_07 | AC | 58 ms
53,532 KB |
testcase_08 | AC | 56 ms
52,440 KB |
testcase_09 | AC | 57 ms
53,520 KB |
testcase_10 | AC | 56 ms
52,468 KB |
testcase_11 | AC | 58 ms
53,520 KB |
testcase_12 | AC | 59 ms
51,480 KB |
testcase_13 | AC | 675 ms
69,792 KB |
testcase_14 | AC | 684 ms
69,628 KB |
testcase_15 | AC | 624 ms
67,192 KB |
testcase_16 | AC | 759 ms
69,860 KB |
testcase_17 | AC | 616 ms
67,084 KB |
testcase_18 | AC | 697 ms
69,664 KB |
testcase_19 | AC | 750 ms
69,808 KB |
testcase_20 | AC | 764 ms
69,972 KB |
ソースコード
package 練習; import java.io.PrintWriter; import java.util.Scanner; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Iterator; import java.util.Arrays; public class main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); PrintWriter pw=new PrintWriter(System.out); int h=sc.nextInt(); int w=sc.nextInt(); int n=sc.nextInt(); int x=0; int y=0; char[] s=new char[n]; int[] k=new int[n]; for(int i=0;i<n;i++){ s[i]=sc.next().toCharArray()[0]; k[i]=Integer.parseInt(sc.next()); } for(int i=n-1;i>=0;i--){ if(s[i]=='R'&&k[i]==y){ x=(x-1+w)%w; }else if(s[i]=='C'&&k[i]==x){ y=(y-1+h)%h; } } if((x+y)%2==0){ pw.println("white"); }else if((x+y)%2==1){ pw.println("black"); } pw.close(); sc.close(); } private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }