結果
| 問題 | No.1142 XOR と XOR |
| コンテスト | |
| ユーザー |
FF256grhy
|
| 提出日時 | 2020-07-31 22:49:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 154 ms / 2,000 ms |
| コード長 | 4,525 bytes |
| コンパイル時間 | 3,172 ms |
| コンパイル使用メモリ | 199,304 KB |
| 最終ジャッジ日時 | 2025-01-12 11:07:42 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l) ; i < (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l) ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r) ; i >= (l); --i)
#define inc(i, n) incID(i, 0, n)
#define dec(i, n) decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) < (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin = [](auto & a, auto b) { return (b < a ? a = b, true : false); };
auto setmax = [](auto & a, auto b) { return (b > a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T > void OUT(T && a ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }
// ---- ----
template<LL M> class ModInt {
private:
LL v;
pair<LL, LL> ext_gcd(LL a, LL b) {
if(b == 0) { assert(a == 1); return { 1, 0 }; }
auto p = ext_gcd(b, a % b);
return { p.SE, p.FI - (a / b) * p.SE };
}
public:
ModInt(LL vv = 0) { v = vv; if(abs(v) >= M) { v %= M; } if(v < 0) { v += M; } }
LL get_v() { return v; }
ModInt inv() { return ext_gcd(M, v).SE; }
ModInt exp(LL b) {
ModInt p = 1, a = v; if(b < 0) { a = a.inv(); b = -b; }
while(b) { if(b & 1) { p *= a; } a *= a; b >>= 1; }
return p;
}
friend bool operator< (ModInt a, ModInt b) { return (a.v < b.v); }
friend bool operator> (ModInt a, ModInt b) { return (a.v > b.v); }
friend bool operator<=(ModInt a, ModInt b) { return (a.v <= b.v); }
friend bool operator>=(ModInt a, ModInt b) { return (a.v >= b.v); }
friend bool operator==(ModInt a, ModInt b) { return (a.v == b.v); }
friend bool operator!=(ModInt a, ModInt b) { return (a.v != b.v); }
friend ModInt operator+ (ModInt a ) { return ModInt(+a.v); }
friend ModInt operator- (ModInt a ) { return ModInt(-a.v); }
friend ModInt operator+ (ModInt a, ModInt b) { return ModInt(a.v + b.v); }
friend ModInt operator- (ModInt a, ModInt b) { return ModInt(a.v - b.v); }
friend ModInt operator* (ModInt a, ModInt b) { return ModInt(a.v * b.v); }
friend ModInt operator/ (ModInt a, ModInt b) { return a * b.inv(); }
friend ModInt operator^ (ModInt a, LL b) { return a.exp(b); }
friend ModInt & operator+=(ModInt & a, ModInt b) { return (a = a + b); }
friend ModInt & operator-=(ModInt & a, ModInt b) { return (a = a - b); }
friend ModInt & operator*=(ModInt & a, ModInt b) { return (a = a * b); }
friend ModInt & operator/=(ModInt & a, ModInt b) { return (a = a / b); }
friend ModInt & operator^=(ModInt & a, LL b) { return (a = a ^ b); }
friend istream & operator>>(istream & s, ModInt & b) { s >> b.v; b = ModInt(b.v); return s; }
friend ostream & operator<<(ostream & s, ModInt b) { return (s << b.v); }
};
// ----
using MI = ModInt<1'000'000'007>;
template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
return s;
}
int main() {
IN(int, n, m, k);
vector<LL> a(n), b(m);
cin >> a >> b;
vector<MI> s(1 << 10), t(1 << 10), S(1 << 10), T(1 << 10);
s[0] = t[0] = 1;
{
int x = 0;
RF(e, a) { x ^= e; s[x] += 1; }
}
{
int x = 0;
RF(e, b) { x ^= e; t[x] += 1; }
}
inc(x, 1 << 10) {
inc(y, 1 << 10) {
S[x ^ y] += s[x] * (x == y ? s[x] - 1: s[y]);
T[x ^ y] += t[x] * (x == y ? t[x] - 1: t[y]);
}
}
MI ans = 0;
inc(i, 1 << 10) { ans += S[i] * T[i ^ k]; }
OUT(ans / 4);
}
FF256grhy