結果

問題 No.1863 Xor Sum 2...?
ユーザー tentententen
提出日時 2022-03-08 12:48:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 1,592 bytes
コンパイル時間 4,464 ms
コンパイル使用メモリ 73,968 KB
実行使用メモリ 56,948 KB
最終ジャッジ日時 2023-09-30 18:28:58
合計ジャッジ時間 13,022 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,392 KB
testcase_01 AC 43 ms
49,312 KB
testcase_02 AC 42 ms
49,256 KB
testcase_03 AC 43 ms
49,440 KB
testcase_04 AC 44 ms
49,284 KB
testcase_05 AC 139 ms
54,272 KB
testcase_06 AC 105 ms
52,660 KB
testcase_07 AC 159 ms
56,196 KB
testcase_08 AC 157 ms
54,768 KB
testcase_09 AC 218 ms
56,460 KB
testcase_10 AC 218 ms
56,308 KB
testcase_11 AC 191 ms
55,712 KB
testcase_12 AC 168 ms
55,720 KB
testcase_13 AC 195 ms
56,436 KB
testcase_14 AC 196 ms
55,780 KB
testcase_15 AC 212 ms
56,252 KB
testcase_16 AC 202 ms
55,996 KB
testcase_17 AC 177 ms
55,640 KB
testcase_18 AC 129 ms
54,808 KB
testcase_19 AC 154 ms
54,808 KB
testcase_20 AC 190 ms
55,576 KB
testcase_21 AC 202 ms
56,036 KB
testcase_22 AC 157 ms
55,316 KB
testcase_23 AC 243 ms
55,892 KB
testcase_24 AC 247 ms
55,860 KB
testcase_25 AC 261 ms
56,084 KB
testcase_26 AC 259 ms
56,948 KB
testcase_27 AC 253 ms
56,284 KB
testcase_28 AC 259 ms
56,116 KB
testcase_29 AC 260 ms
56,140 KB
testcase_30 AC 234 ms
55,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] values = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            values[i] = sc.nextInt();
        }
        boolean[] bits = new boolean[n + 1];
        for (int i = 1; i <= n; i++) {
            bits[i] = (sc.nextInt() == 1);
        }
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            int j = i;
            boolean cbit = false;
            int current = 0;
            while (j <= n && current + values[j] == (current | values[j])) {
                cbit ^= bits[j];
                current += values[j];
                if (!cbit) {
                    ans++;
                }
                j++;
            }
        }
        System.out.println(ans);
    }
}


class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0