結果
問題 |
No.1142 XOR と XOR
|
ユーザー |
|
提出日時 | 2020-07-31 23:36:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 1,355 bytes |
コンパイル時間 | 959 ms |
コンパイル使用メモリ | 89,376 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 03:36:26 |
合計ジャッジ時間 | 3,324 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<vector> #include<map> #include<set> #include<string> #include<queue> #include<stack> #include<complex> using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define INF (1<<29) #define LINF (1LL<<60) #define EPS (1e-10) #define PI 3.1415926535897932384626433832795028 typedef long long Int; typedef pair<Int, Int> P; typedef long double Real; typedef complex<Real> CP; Int a, b; Int accum_a, accum_b; Int cnt_a[1 << 10], cnt_b[1 << 10]; Int pcnt_a[1<<10], pcnt_b[1<<10]; Int n, m, k; int main(){ cin >> n >> m >> k; cnt_a[0]++; for(Int i = 0;i < n;i++){ cin >> a; accum_a ^= a; cnt_a[accum_a]++; } cnt_b[0]++; for(Int i = 0;i < m;i++){ cin >> b; accum_b ^= b; cnt_b[accum_b]++; } for(Int i = 0;i < (1 << 10);i++){ (pcnt_a[0] += cnt_a[i] * (cnt_a[i]-1) / 2) %= MOD; (pcnt_b[0] += cnt_b[i] * (cnt_b[i]-1) / 2) %= MOD; for(Int j = i+1;j < (1 << 10);j++){ (pcnt_a[i^j] += cnt_a[i] * cnt_a[j] % MOD) %= MOD; (pcnt_b[i^j] += cnt_b[i] * cnt_b[j] % MOD) %= MOD; } } Int ans = 0; for(Int i = 0;i < (1<<10);i++){ (ans += pcnt_a[i] * pcnt_b[i^k] % MOD) %= MOD; } cout << ans << endl; return 0; }