結果

問題 No.462 6日知らずのコンピュータ
ユーザー peroonperoon
提出日時 2019-04-28 22:18:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,667 bytes
コンパイル時間 1,731 ms
コンパイル使用メモリ 171,004 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 07:33:28
合計ジャッジ時間 6,297 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 RE -
testcase_24 AC 2 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 WA -
testcase_30 AC 1 ms
4,380 KB
testcase_31 WA -
testcase_32 AC 1 ms
4,380 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
4,376 KB
testcase_36 WA -
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 WA -
testcase_47 RE -
testcase_48 WA -
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 1 ms
4,376 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,376 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 RE -
testcase_62 AC 2 ms
4,376 KB
testcase_63 AC 1 ms
4,380 KB
testcase_64 AC 1 ms
4,376 KB
testcase_65 AC 2 ms
4,376 KB
testcase_66 AC 2 ms
4,380 KB
testcase_67 AC 1 ms
4,380 KB
testcase_68 AC 1 ms
4,376 KB
testcase_69 AC 2 ms
4,376 KB
testcase_70 AC 2 ms
4,380 KB
testcase_71 AC 1 ms
4,380 KB
testcase_72 AC 2 ms
4,376 KB
testcase_73 AC 2 ms
4,380 KB
testcase_74 AC 2 ms
4,376 KB
testcase_75 AC 2 ms
4,380 KB
testcase_76 AC 2 ms
4,380 KB
testcase_77 AC 2 ms
4,380 KB
testcase_78 AC 1 ms
4,380 KB
testcase_79 AC 2 ms
4,380 KB
testcase_80 AC 2 ms
4,380 KB
testcase_81 AC 1 ms
4,376 KB
testcase_82 AC 1 ms
4,380 KB
testcase_83 AC 2 ms
4,376 KB
testcase_84 AC 1 ms
4,376 KB
testcase_85 AC 1 ms
4,380 KB
testcase_86 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

ll N, K;

ll bit_diff(ll a, ll b){
    ll count = 0;
    FOR(i, 0, N){
        ll f0 = (a>>i)&1;
        ll f1 = (b>>i)&1;

        if(f0==f1){
            continue;
        }
        else if(f0==0 && f1==1){
            count++;
        }
        else if(f0==1 && f1==0){
            return -1;
        }
    }
    return count;
}

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

    // input
    cin >> N >> K;

    if(K==0){
        ll ans = 1;
        FOR(i, 1, N+1){
            ans *= i;
            ans %= mod;
        }
        p(ans);
        return 0;
    }

    vector<ll> A(N);
    FOR(i, 0, K){
        ll a;
        cin >> a;
        A[i] = a;
    }
    A.push_back(0);
    A.push_back((1<<N)-1);
    sort(ALL(A));
    
    ll L = A.size();
    ll ans = 1;
    FOR(i, 0, L-1){
        ll a = A[i];
        ll b = A[i+1];

        ll diff = bit_diff(a, b);
        if(diff==-1){
            p(0);
            return 0;
        }
        else if(diff==0){
            // 
        }
        else{
            FOR(i, 1, diff+1){
                ans *= i;
                ans %= mod;
            }
        }
    }

    p(ans);
    
    return 0;
}
0