結果
問題 | No.1410 A lot of Bit Operations |
ユーザー |
![]() |
提出日時 | 2021-02-26 22:44:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,184 bytes |
コンパイル時間 | 4,446 ms |
コンパイル使用メモリ | 250,912 KB |
最終ジャッジ日時 | 2025-01-19 06:16:17 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 44 |
ソースコード
#include <stdio.h>#include <atcoder/all>#include <bits/stdc++.h>using namespace std;using namespace atcoder;using mint = modint1000000007;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf 1000000001int main(){long long N;cin>>N;string S;cin>>S;mint ans = 0;if(N<=2){rep(_,8){if(S[_]=='-')continue;rep(i,1<<N){rep(j,1<<N){rep(k,1<<N){int t = i;int cur = 0;rep(l,N){int x = (i>>l)&1;int y = (j>>l)&1;cur += (_>>(x*2+y)) * (1<<l);}int c2 = cur ^ ((1<<N)-1);if((cur-k)*(c2-k)<=0)ans++;}}}}}else{rep(_,8){if(S[_]=='-')continue;ans += mint(4).pow(N);rep(i,2){rep(j,2){int x = (_>>(2*i+j))&1;int t = _;if(x==0)t = 15-t;mint cnt = 0;rep(k,2){rep(l,2){int y = (t>>(2*k+l))&1;if(y)cnt++;else cnt--;}}// cout<<t<<','<<cnt.val()<<endl;ans += mint(2).pow(N-1) * mint(4).pow(N-1);ans += (mint(2).pow(N-1)-1) * cnt * mint(4).pow(N-2);}}}}cout<<ans.val()<<endl;return 0;}