結果
問題 | No.74 貯金箱の退屈 |
ユーザー | Grenache |
提出日時 | 2016-08-06 23:01:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 67 ms / 5,000 ms |
コード長 | 2,944 bytes |
コンパイル時間 | 7,077 ms |
コンパイル使用メモリ | 78,416 KB |
実行使用メモリ | 38,056 KB |
最終ジャッジ日時 | 2024-04-24 19:31:06 |
合計ジャッジ時間 | 6,396 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
37,516 KB |
testcase_01 | AC | 54 ms
37,560 KB |
testcase_02 | AC | 55 ms
37,488 KB |
testcase_03 | AC | 56 ms
37,824 KB |
testcase_04 | AC | 60 ms
37,172 KB |
testcase_05 | AC | 67 ms
37,812 KB |
testcase_06 | AC | 59 ms
37,828 KB |
testcase_07 | AC | 54 ms
37,696 KB |
testcase_08 | AC | 54 ms
37,876 KB |
testcase_09 | AC | 63 ms
37,544 KB |
testcase_10 | AC | 56 ms
37,876 KB |
testcase_11 | AC | 52 ms
37,612 KB |
testcase_12 | AC | 57 ms
37,604 KB |
testcase_13 | AC | 56 ms
37,868 KB |
testcase_14 | AC | 58 ms
37,408 KB |
testcase_15 | AC | 61 ms
38,056 KB |
testcase_16 | AC | 57 ms
37,772 KB |
testcase_17 | AC | 56 ms
37,268 KB |
testcase_18 | AC | 54 ms
37,828 KB |
testcase_19 | AC | 55 ms
37,448 KB |
testcase_20 | AC | 56 ms
37,720 KB |
testcase_21 | AC | 55 ms
37,204 KB |
testcase_22 | AC | 54 ms
37,604 KB |
testcase_23 | AC | 55 ms
37,556 KB |
testcase_24 | AC | 56 ms
37,816 KB |
testcase_25 | AC | 55 ms
37,588 KB |
testcase_26 | AC | 60 ms
37,776 KB |
testcase_27 | AC | 58 ms
37,824 KB |
testcase_28 | AC | 56 ms
37,876 KB |
testcase_29 | AC | 59 ms
37,208 KB |
testcase_30 | AC | 58 ms
37,540 KB |
testcase_31 | AC | 54 ms
37,280 KB |
testcase_32 | AC | 54 ms
37,880 KB |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder74 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); int[] d = new int[n]; for (int i = 0; i < n; i++) { d[i] = sc.nextInt(); } int[] w = new int[n]; BitSet[] ma = new BitSet[n + 1]; for (int i = 0; i < n + 1; i++) { ma[i] = new BitSet(n); } for (int i = 0; i < n; i++) { w[i] = sc.nextInt(); if (w[i] == 1) { ma[0].set(i); } } for (int i = 0; i < n; i++) { int tmp = (i + d[i]) % n; ma[i + 1].set(tmp); int tmp2 = ((i - d[i]) % n + n) % n; ma[i + 1].set(tmp2); } int cnt = 0; int p = 1; for (int i = 0; i < n; i++) { boolean flag = false; for (int j = p; j < n + 1; j++) { if (ma[j].get(i)) { flag = true; BitSet tmp = ma[j]; ma[j] = ma[p]; ma[p] = tmp; break; } } if (flag) { cnt++; for (int j = 1; j < n + 1; j++) { if (j != p && ma[j].get(i)) { ma[j].xor(ma[p]); } } if (ma[0].get(i)) { ma[p].clear(); } p++; } else { boolean tmp = false; for (int j = 0; j < p; j++) { tmp ^= ma[j].get(i); } if (tmp) { cnt++; } } } if (cnt == n) { pr.println("Yes"); } else { // pr.println(n); // pr.println(cnt); pr.println("No"); } pr.close(); sc.close(); } @SuppressWarnings("unused") 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(); it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).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); } } }