Practice Round APAC test 2017--Problem B. Robot Rock Band
2016-10-14 11:02
459 查看
Problem B. Robot Rock Band
题意
given four lists A, B, C, D containing N numbers each, how many ways are there to choose one number a from list A, one number b from list B, and so on, such that a^b^c^d = K? (Here ^ represents the bitwise XOR operation.)题解
a ^ b ^ c ^ d = k⇒
a ^ b ^ k = c ^ d
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 5; int a[maxn], b[maxn], c[maxn], d[maxn]; map<int, long long> mp; int T, n, k; int main(){ freopen("B-large-practice.in", "r", stdin); freopen("B-large-practice.txt", "w", stdout); cin >> T; for(int _ = 1; _ <= T; ++_){ cin >> n >> k; for(int i = 0; i < n; ++i) cin >> a[i]; for(int i = 0; i < n; ++i) cin >> b[i]; for(int i = 0; i < n; ++i) cin >> c[i]; for(int i = 0; i < n; ++i) cin >> d[i]; mp.clear(); for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j) mp[c[i] ^ d[j]]++; } long long ans = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ int t = a[i] ^ b[j] ^ k; if(mp.find(t) != mp.end()) ans += mp[t]; } } printf("Case #%d: %I64d\n", _, ans); } return 0; }
相关文章推荐
- Problem B. Robot Rock Band Google APAC 2017 University Test Practice Round
- Practice Round APAC test 2017——Problem B. Robot Rock Band
- Practice Round APAC test 2017——1.Problem A. Lazy Spelling Bee
- Problem A. Lazy Spelling Bee Google APAC 2017 University Test Practice Round
- Practice Round APAC test 2017——Problem D. Sums of Sums
- Practice Round APAC test 2017--Problem A. Lazy Spelling Bee
- Problem C. Not So Random Google APAC 2017 University Test Practice Round
- Practice Round APAC test 2017——Problem C. Not So Random
- Problem B. Safe Squares Google APAC 2017 University Test Round C
- Problem C. Codejamon Cipher Google APAC 2017 University Test Round D
- Round D APAC Test 2017 Problem D. Stretch Rope (C++)
- Round D APAC Test 2017--Problem C. Codejamon Cipher(dp)
- Problem C. Evaluation Google APAC 2017 University Test Round C
- Problem B. Beautiful Numbers Google APAC 2017 University Test Round E
- Round B APAC Test 2017 Problem B. Sherlock and Watson Gym Secrets
- Round A APAC Test 2017 Problem C. Jane's Flower Shop 二分、高精度要求
- Problem A. Sherlock and Parentheses Google APAC 2017 University Test Round B
- Problem C. Partioning Number Google APAC 2017 University Test Round E
- Problem A. Country Leader Google APAC 2017 University Test Round A
- Round D APAC Test 2017 Problem A. Vote (C++)