結果

問題 No.1142 XOR と XOR
ユーザー 37zigen37zigen
提出日時 2020-08-01 00:24:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,474 bytes
コンパイル時間 3,175 ms
コンパイル使用メモリ 75,524 KB
実行使用メモリ 57,312 KB
最終ジャッジ日時 2023-09-21 04:08:40
合計ジャッジ時間 8,476 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
51,812 KB
testcase_01 AC 97 ms
51,824 KB
testcase_02 AC 98 ms
51,612 KB
testcase_03 AC 174 ms
57,312 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 166 ms
55,356 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 100 ms
52,032 KB
testcase_12 AC 98 ms
51,784 KB
testcase_13 AC 98 ms
51,720 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 169 ms
55,612 KB
testcase_18 AC 145 ms
52,620 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 158 ms
53,104 KB
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	final long MOD=(long)1e9+7;

	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int M=sc.nextInt();
		int K=sc.nextInt();
		int[] A=new int[N];
		int[] suma=new int[N+1];
		int[] B=new int[M];
		int[] sumb=new int[M+1];
		long[] cnta=new long[1<<10];
		long[] cntb=new long[1<<10];
		for (int i=0;i<N;++i) {
			A[i]=sc.nextInt();
			suma[i+1]=suma[i]^A[i];
		}
		for (int a:suma) cnta[a]++;
		for (int i=0;i<M;++i) {
			B[i]=sc.nextInt();
			sumb[i+1]=sumb[i]^B[i];
		}
		for (int b:sumb) cntb[b]++;
		long[][] cnt=new long[2][1<<10];
		for (int i=0;i<1<<10;++i) {
			for (int j=i+1;j<1<<10;++j) {
				int v=i^j;
				long add=cnta[i]*cnta[j]%MOD;
				cnt[0][v]=(cnt[0][v]+add)%MOD;
			}
			cnt[0][0]=(cnt[0][0]+cnta[i]*(cnta[i]-1)/2%MOD)%MOD;
		}
		
		for (int i=0;i<1<<10;++i) {
			for (int j=i+1;j<1<<10;++j) {
				int v=i^j;
				long add=cntb[i]*cntb[j]%MOD;
				cnt[1][v]=(cnt[1][v]+add)%MOD;
			}
			cnt[1][0]=(cnt[1][0]+cntb[i]*(cntb[i]-1)/2%MOD)%MOD;
		}
		
		
		long ans=0;
		for (int i=0;i<1<<10;++i) {
			for (int j=0;j<1<<10;++j) {
				if ((i^j)!=K) continue;
				ans+=cnt[0][i]*cnt[1][j]%MOD;
			}
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
	
	class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        if (!hasNext()) throw new NoSuchElementException();
	        long n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	    public int nextInt() {
	    	return (int)nextLong();
	    }
	}
}

0