結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー n_vipn_vip
提出日時 2015-04-16 23:35:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 5,176 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 102,292 KB
実行使用メモリ 101,736 KB
最終ジャッジ日時 2023-09-17 16:23:58
合計ジャッジ時間 81,177 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

ll MOD=2;
ll modpow(ll r,ll n,ll m=MOD){
  n=(n%(m-1)+m-1)%(m-1);
  if(n==0)return 1ll;
  ll tmp=modpow(r,n/2,m);
  return tmp*tmp%m*(n%2?r:1ll)%m;
}
double EPS=1e-12;
struct modInt{
  ll v,mod;
  modInt(ll v=0,ll mod=MOD):v(v),mod(mod){}
  modInt operator+(const int &n){return (v+n%mod)%mod;};
  modInt operator-(const int &n){return (v+mod-n%mod)%mod;};
  modInt operator*(const int &n){return v*(n%mod)%mod;};
  modInt operator/(const int &n){return v*modpow(n%mod,-1,mod)%mod;};
  modInt &operator+=(const modInt &n){(v+=n.v%mod)%=mod;return *this;};
  modInt &operator-=(const modInt &n){(v+=mod-n.v%mod)%=mod;return *this;};
  modInt &operator*=(const modInt &n){(v*=n.v%mod)%=mod;return *this;};
  modInt &operator/=(const modInt &n){(v*=modpow(n.v,-1,mod))%=mod;return *this;};
  modInt &operator+=(const int &n){(v+=n%mod)%=mod;return *this;};
  modInt &operator-=(const int &n){(v+=mod-n%mod)%=mod;return *this;};
  modInt &operator*=(const int &n){(v*=n%mod)%=mod;return *this;};
  modInt &operator/=(const int &n){(v*=modpow(n,-1,mod))%=mod;return *this;};
};
modInt operator-(const modInt &n){return (n.mod-n.v)%n.mod;}
modInt operator++(const modInt &n){return (n.v+1)%n.mod;}
modInt operator--(const modInt &n){return (n.v+n.mod-1)%n.mod;}
modInt operator+(const modInt &n,const modInt &m){return (n.v+m.v)%n.mod;};
modInt operator-(const modInt &n,const modInt &m){return n+(-m);};
  //modInt operator*(const modInt &n){return v*n.v%mod;};
modInt operator*(const modInt &n,modInt m){return n.v*m.v%n.mod;};
modInt operator/(const modInt &n,modInt &m){return n.v*modpow(m.v%n.mod,-1,n.mod)%n.mod;};
/*modInt operator+(const int &n,modInt m){return m+n;};
modInt operator-(const int &n,modInt m){return -(m-n);};
modInt operator*(const int &n,modInt m){return m*n;};
modInt operator/(const int &n,const modInt &m){return n*modpow(m.v,-1,m.mod)%m.mod;};*/
ostream& operator<<(ostream &os,const modInt &n){return os<<n.v;};

typedef vector<vector<ll> > matl;
typedef vector<vector<double> > matd;
template<class T> vector<T> operator*(const T &a,vector<T> v){
  rep(i,v.size()) v[i]=v[i]*a;
  return v;
}
template<class T> vector<T> operator+(vector<T> v,const vector<T> &w){
  rep(i,v.size()) v[i]=v[i]+w[i];
  return v;
}
template<class T> vv<T> matE(T n){
  vv<T> re(n,vector<T>(n));
  rep(i,n) re[i][i]=1;
  return re;
}
template<class T> vv<T>matE(const vv<T> &mat){
  vv<T> re(mat.size(),vector<T>(mat.size()));
  rep(i,mat.size()) re[i][i]=1;
  return re;
}

template<class T> vv<T> transpose(const vv<T> &a,vector<vector<T>> &re){
  re.resize(a[0].size(),vector<T>(a.size()));
  rep(i,a[0].size()) rep(j,a.size()) re[i][j]=a[j][i];
  return re;
}

template<class T> T operator*(const vector<T> &a,const vector<T> &b){
  T re(0);
  rep(i,a.size())re+=a[i]*b[i];
  return re;
}
template<class T> vv<T> operator*(const vv<T> &a,const vv<T> &b_){
  vv<T> b,re(a.size(),vector<T>(b_[0].size()));
  transpose(b_,b);
  rep(i,a.size()) rep(j,b[0].size()) re[i][j]=a[i]*b[j];
  return re;
}
template<class T> vv<T> pow(vv<T> a,ll n){
  if(n==0)return matE(a);
  if(n%2) return a*pow(a,n-1);
  vv<T> re;
  re=pow(a,n/2);
  return re*re;
}

bool hasInv(modInt n){return n.v!=0;};
bool hasInv(double n){return abs(n)>EPS;}
template<class T> int gyohen(vv<T> &a){
  ll i,j,k,n=a.size(),agcd,m=a[0].size(),nul=0;
  T div(1);
  rep(i,min(n,m)){
    int non0=-1;
    for(j=i-nul;j<n;++j) if(hasInv(a[j][i])){non0=j; break;}
    if(non0<0){ ++nul; continue;}
    a[non0]=(1/a[non0][i])*a[non0];
    div/=a[non0][i];
    if(non0!=i-nul){swap(a[non0],a[i-nul]); div*=-1;}
    rep(j,n){
      if(j==i-nul)continue;
      if(hasInv(a[j][i])){
	//	if(a[j][i]<0){a[j]=-a[j]; div*=-1;}
	a[j]=a[j]+(-a[j][i]*a[i-nul]);
      }
    }
  }
  return n-nul;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k;
  int n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n)
    cin>>v[i];
  vv<modInt> a(n,vector<modInt>(60,modInt(0)));
  rep(i,60)rep(j,n)
    if(v[j]>>i&1)
      a[j][i]=1;
  int d=gyohen(a);
  cout<<(1ll<<d)<<endl;
  return 0;
}
0