結果

問題 No.1410 A lot of Bit Operations
ユーザー leaf_1415leaf_1415
提出日時 2021-02-26 22:57:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,019 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 83,716 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 13:38:44
合計ジャッジ時間 1,628 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define reps(x, s) for(llint (x) = 0; (x) < (llint)(s).size(); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define ceildiv(x, y) (((x)+(y)-1) / (y))
#define all(x) (x).begin(),(x).end()
#define outl(x) cout << x << endl
#define SP << " " << 
#define inf 1e18
#define mod 1000000007

using namespace std;

typedef long long llint;
typedef long long ll;
typedef pair<llint, llint> P;
bool exceed(ll x, ll y, ll m){return x >= m / y + 1;} 

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

ll n;
string s;

ll func(ll a, ll b, ll k)
{
	ll ret = 0;
	rep(i, 0, n-1){
		ll p = ((a>>i)&1) | (((b>>i)&1)<<1);
		ret |= ((k>>p)&1) << i;
	}
	return ret;
}

ll get(ll b)
{
	ll ret = 0;
	ret += b * b % mod * modpow(4, n-2) % mod * (modpow(2, n-1) + mod - 1) % mod, ret %= mod;
	ret += mod - (4-b) * b % mod * modpow(4, n-2) % mod * (modpow(2, n-1) + mod - 1) % mod, ret %= mod;
	ret += b * modpow(4, n-1) % mod * modpow(2, n-1) % mod, ret %= mod;
	
	return ret;
}

ll calc(ll k)
{
	if(n <= 5){
		ll N = 1<<n, ret = 0;
		rep(p, 0, N-1) rep(q, 0, N-1) rep(r, 0, N-1){
			if((func(p, q, k) - r) * (func(p, q, 15-k) - r) <= 0) ret++;
		}
		return ret;
	}
	
	ll b = 0;
	rep(i, 0, 3) if(k & (1<<i)) b++;
	
	ll ret = get(b);
	ret += get(4-b), ret %= mod;
	ret += modpow(4, n), ret %= mod;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;
	ll ans = 0;
	rep(i, 0, 7){
		if(s[i] == 'o') ans += calc(i), ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}
0