結果
問題 | No.1142 XOR と XOR |
ユーザー | ccppjsrb |
提出日時 | 2020-07-31 22:56:21 |
言語 | Go (1.23.4) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,691 bytes |
コンパイル時間 | 15,439 ms |
コンパイル使用メモリ | 230,140 KB |
実行使用メモリ | 14,572 KB |
最終ジャッジ日時 | 2024-07-06 20:28:53 |
合計ジャッジ時間 | 19,233 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
11,136 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
ソースコード
package mainimport ("bufio""fmt""os""strconv")func configure(scanner *bufio.Scanner) {scanner.Split(bufio.ScanWords)scanner.Buffer(make([]byte, 1000005), 1000005)}func getNextString(scanner *bufio.Scanner) string {scanned := scanner.Scan()if !scanned {panic("scan failed")}return scanner.Text()}func getNextInt(scanner *bufio.Scanner) int {i, _ := strconv.Atoi(getNextString(scanner))return i}func getNextInt64(scanner *bufio.Scanner) int64 {i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)return i}func getNextFloat64(scanner *bufio.Scanner) float64 {i, _ := strconv.ParseFloat(getNextString(scanner), 64)return i}func main() {fp := os.Stdinwfp := os.Stdoutextra := 0if os.Getenv("I") == "IronMan" {fp, _ = os.Open(os.Getenv("END_GAME"))extra = 100}scanner := bufio.NewScanner(fp)configure(scanner)writer := bufio.NewWriter(wfp)defer func() {r := recover()if r != nil {fmt.Fprintln(writer, r)}writer.Flush()}()solve(scanner, writer)for i := 0; i < extra; i++ {fmt.Fprintln(writer, "-----------------------------------")solve(scanner, writer)}}func solve(scanner *bufio.Scanner, writer *bufio.Writer) {n := getNextInt(scanner)m := getNextInt(scanner)k := getNextInt(scanner)aa := make([]int, n)bb := make([]int, m)cca := make([]mint, 1024)ccb := make([]mint, 1024)for i := 0; i < n; i++ {aa[i] = getNextInt(scanner)}for i := 0; i < m; i++ {bb[i] = getNextInt(scanner)}x := 0for r := 0; r < n; r++ {x = x ^ aa[r]y := xfor l := 0; l <= r; l++ {cca[y]++y = y ^ aa[l]}}x = 0for r := 0; r < m; r++ {x = x ^ bb[r]y := xfor l := 0; l <= r; l++ {ccb[y]++y = y ^ bb[l]}}var ans mintfor i := 0; i < 1024; i++ {ans.addAs(cca[i].mul(ccb[i^k]))}fmt.Fprintln(writer, ans)}type mint int64func (mt mint) mod() mint {m := mint(1e9 + 7)mt %= mif mt < 0 {return mt + m}return mt}func (mt mint) inv() mint {return mt.pow(mint(0).sub(2))}func (mt mint) pow(n mint) mint {p := mint(1)for n > 0 {if n&1 == 1 {p.mulAs(mt)}mt.mulAs(mt)n >>= 1}return p}func (mt mint) add(x mint) mint {return (mt + x).mod()}func (mt mint) sub(x mint) mint {return (mt - x).mod()}func (mt mint) mul(x mint) mint {return (mt * x).mod()}func (mt mint) div(x mint) mint {return mt.mul(x.inv())}func (mt *mint) addAs(x mint) *mint {*mt = mt.add(x)return mt}func (mt *mint) subAs(x mint) *mint {*mt = mt.sub(x)return mt}func (mt *mint) mulAs(x mint) *mint {*mt = mt.mul(x)return mt}func (mt *mint) divAs(x mint) *mint {*mt = mt.div(x)return mt}