結果

問題 No.1142 XOR と XOR
ユーザー saksham gargsaksham garg
提出日時 2020-11-21 16:25:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 4,089 bytes
コンパイル時間 1,908 ms
コンパイル使用メモリ 170,544 KB
実行使用メモリ 4,752 KB
最終ジャッジ日時 2023-09-30 21:57:26
合計ジャッジ時間 3,564 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 5 ms
4,376 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 38 ms
4,612 KB
testcase_04 AC 29 ms
4,676 KB
testcase_05 AC 24 ms
4,416 KB
testcase_06 AC 29 ms
4,408 KB
testcase_07 AC 28 ms
4,748 KB
testcase_08 AC 35 ms
4,748 KB
testcase_09 AC 35 ms
4,752 KB
testcase_10 AC 35 ms
4,680 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 21 ms
4,380 KB
testcase_15 AC 20 ms
4,376 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 22 ms
4,380 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 29 ms
4,376 KB
testcase_20 AC 22 ms
4,380 KB
testcase_21 AC 14 ms
4,376 KB
testcase_22 AC 10 ms
4,380 KB
testcase_23 AC 27 ms
4,376 KB
testcase_24 AC 30 ms
4,380 KB
testcase_25 AC 19 ms
4,380 KB
testcase_26 AC 29 ms
4,380 KB
testcase_27 AC 23 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//FIRST THINK THEN CODE.

#include <bits/stdc++.h>


using namespace std;

typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vld vector<ld>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define vvld vector<vector<ld>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M = 1000000007;
const ll MM = 998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define trace(...)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

template<typename T, typename F>
void chmax( T &a, F b) {
  if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
  if (b < a)a = b;
}



/* if you want to multiply 2 64 bit numbers mod c.
 i.e a*b%c.
 this function will help  in preventing "overflow".
*/

ll mulmod(ll a, ll b, ll c) {

  ll ans = 0;
  ll y = a % c;
  while (b) {
    if (b & 1) {
      (ans += y) %= c;
    }
    y = y * 2 % c;
    b >>= 1;
  }
  return ans;

}



ll powM(ll a, ll b, ll m)
{
  if (b < 0)return 0;
  if (a <= 0)return 0;
  a %= m;

  ll ans = 1LL;
  while (b)
  {
    if (b & 1)ans = ans * a % m;
    //ans = mulmod(ans, a, m);
    a = a * a % m;
    //a = mulmod(a, a, m);
    b >>= 1;
  }

  return ans;
}

ll powMbig(ll a, ll b, ll m)
{
  if (a <= 0)return 0;
  a %= m;

  ll ans = 1LL;
  while (b)
  {
    if (b & 1)//ans = ans * a % m;
      ans = mulmod(ans, a, m);
    //a = a * a % m;
    a = mulmod(a, a, m);
    b >>= 1;
  }

  return ans;
}




ll poww(ll a, ll b)
{

  ll ans = 1;
  while (b)
  {
    if (b & 1)ans = ans * a;
    a = a * a;
    b >>= 1;
  }

  return ans;

}


string tostring(ll x) {
  stringstream sss;
  sss << x;
  string ans = sss.str();
  return ans;
}


const ll N = 1e6 + 5;

ll gandu(ll c) {
  return (c * (c - 1) / 2) % M;
}

int main() {

  IOS;

#ifndef ONLINE_JUDGE

  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);

#endif


  ll n, m, k;
  cin >> n >> m >> k;

  vl a(n);
  ll s1 = 0;
  vl f1(2100);
  f1[0] = 1;
  FOR(i, n) {
    ll x; cin >> x;
    s1 ^= x;
    f1[s1]++;
  }
  ll s2 = 0;
  vl f2(2100);

  f2[s2] = 1;

  FOR(i, m) {
    ll x; cin >> x;
    s2 ^= x;
    f2[s2]++;
  }

  vl f3(2100), f4(2100);

  for (ll i = 0; i < 1025; i++) {
    for (ll j = i; j < 1025; j++) {
      if (i == j)(f3[0] += gandu(f1[i])) %= M;
      else (f3[i ^ j] += f1[i] * f1[j] % M) %= M;
    }
  }

  //FOR(i, 4)d2(i, f3[i]);

  for (ll i = 0; i < 1025; i++) {
    for (ll j = i; j < 1025; j++) {
      if (i == j)(f4[0] += gandu(f2[i])) %= M;
      else (f4[i ^ j] += f2[i] * f2[j] % M) %= M;
    }
  }

  ll ans = 0;

  for (ll i = 0; i < 1025; i++) {
    ans = (ans + f3[i] * f4[i ^ k] % M) % M;
  }

  cout << ans << endl;



  return 0;
}

0