結果

問題 No.1410 A lot of Bit Operations
ユーザー beetbeet
提出日時 2021-02-26 23:20:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,533 bytes
コンパイル時間 1,780 ms
コンパイル使用メモリ 197,544 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 14:31:08
合計ジャッジ時間 2,882 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,940 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
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 -
testcase_37 WA -
testcase_38 AC 2 ms
6,944 KB
testcase_39 WA -
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 1 ms
6,944 KB
testcase_43 AC 1 ms
6,944 KB
testcase_44 AC 1 ms
6,940 KB
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}


template<typename T, T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T, T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T, T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE

using M = Mint<Int>;
M solve(Int n,Int pat){
  if(n==0) return M(1);
  Int x=(pat>>0)&1;
  Int y=(pat>>1)&1;
  Int z=(pat>>2)&1;
  Int w=(pat>>3)&1;
  M res=M(4).pow(n);
  // res=0;

  res+=M(2).pow(n-1)*M(4).pow(n);

  M p(x+y+z+w);
  M q(4-(x+y+z+w));
  if(n>=2){
    res+=p*p*(M(2).pow(n-1)-M(1))*M(4).pow(n-2);
    res-=q*q*(M(2).pow(n-1)-M(1))*M(4).pow(n-2);
  }
  // cout<<n<<' '<<pat<<":"<<res<<endl;
  return res;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;
  string s;
  cin>>s;

  M ans{0};
  for(Int p=0;p<8;p++)
    if(s[p]=='o') ans+=solve(n,p);

  cout<<ans<<newl;
  return 0;
}
0