結果
| 問題 |
No.1426 Got a Covered OR
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-11 23:10:50 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,911 bytes |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 33,984 KB |
| 最終ジャッジ日時 | 2025-01-16 22:28:03 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:4:10: fatal error: testlib.h: No such file or directory
4 | #include "testlib.h"
| ^~~~~~~~~~~
compilation terminated.
ソースコード
#include <iostream>
#include <vector>
#include <cassert>
#include "testlib.h"
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> bool chmax(T& m, const T q) { if (m < q) { m = q; return true; } else return false; }
template<typename T> bool chmin(T& m, const T q) { if (q < m) { m = q; return true; } else return false; }
const ll MOD = 1000000007;
ll modpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll modinv(ll i, ll mod) {
return modpow(i, mod - 2, mod);
}
ll fact(ll n, ll mod) {
ll ans = 1;
rep(i, n) {
ans = ans * (i + 1) % mod;
}
return ans;
}
ll comb(ll n, ll a, ll mod) {
ll ans = 1, denom = 1;
rep(i, a) {
ans = ans * (n - i) % mod;
denom = denom * (i + 1) % mod;
}
ans = ans * modinv(denom, mod) % mod;
return ans;
}
ll pow2[35];
ll calc(ll a, ll b, ll c) {
ll ret = 0;
for (int i = 0; i <= b; i++) {
ll v = comb(b, i, MOD) * modpow(pow2[b + c - i] - 1, a, MOD) % MOD;
if (i % 2 == 0) {
ret += v;
ret %= MOD;
}
else {
ret += MOD - v;
ret %= MOD;
}
}
return ret;
}
int main(int argc, char* argv[]) {
registerValidation(argc, argv);
int i;
pow2[0] = 1;
for (i = 0; i < 34; i++) {
pow2[i + 1] = pow2[i] * 2;
}
int n = inf.readInt(1, 100000, "n");
inf.readEoln();
vector<ll> b(n, 0);
for (i = 0; i < n; i++) {
b[i] = inf.readInt(-1, (1 << 30) - 1, "b_i");
assert(b[i] != 0);
if (i != n - 1) {
inf.readSpace();
}
}
inf.readEoln();
inf.readEof();
assert(b[n - 1] != -1);
ll prev = 0;
ll streak = 0;
ll ans = 1;
for (i = 0; i < n; i++) {
if (b[i] == -1)
{
streak++;
}
else {
ll c01 = 0;
ll c11 = 0;
for (int j = 0; j < 32; j++) {
ll x = (prev >> j) % 2;
ll y = (b[i] >> j) % 2;
if (x == 0 && y == 1)
{
c01++;
}
else if (x == 1 && y == 1)
{
c11++;
}
else if (x == 1 && y == 0)
{
cout << 0 << "\n";
return 0;
}
}
ans *= calc(streak + 1, c01, c11);
ans %= MOD;
prev = b[i];
streak = 0;
}
}
cout << ans << "\n";
return 0;
}