結果

問題 No.1142 XOR と XOR
ユーザー saksham gargsaksham garg
提出日時 2020-11-21 16:25:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 4,089 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 174,384 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-23 15:43:45
合計ジャッジ時間 3,189 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,812 KB
testcase_01 AC 6 ms
6,940 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 36 ms
6,940 KB
testcase_04 AC 28 ms
6,940 KB
testcase_05 AC 23 ms
6,940 KB
testcase_06 AC 28 ms
6,940 KB
testcase_07 AC 28 ms
6,940 KB
testcase_08 AC 33 ms
6,944 KB
testcase_09 AC 33 ms
6,944 KB
testcase_10 AC 33 ms
6,940 KB
testcase_11 AC 5 ms
6,940 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 5 ms
6,940 KB
testcase_14 AC 20 ms
6,944 KB
testcase_15 AC 19 ms
6,944 KB
testcase_16 AC 7 ms
6,944 KB
testcase_17 AC 21 ms
6,940 KB
testcase_18 AC 9 ms
6,940 KB
testcase_19 AC 28 ms
6,944 KB
testcase_20 AC 21 ms
6,940 KB
testcase_21 AC 14 ms
6,940 KB
testcase_22 AC 11 ms
6,940 KB
testcase_23 AC 26 ms
6,940 KB
testcase_24 AC 29 ms
6,944 KB
testcase_25 AC 18 ms
6,944 KB
testcase_26 AC 28 ms
6,944 KB
testcase_27 AC 23 ms
6,944 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