結果

問題 No.462 6日知らずのコンピュータ
ユーザー ふっぴーふっぴー
提出日時 2017-05-03 15:12:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,160 bytes
コンパイル時間 1,769 ms
コンパイル使用メモリ 175,232 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-12 07:58:19
合計ジャッジ時間 4,398 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	int n,k,i,j;
	cin>>n>>k;
	vl dp(n+1);
	dp[0]=1;
	loop(i,1,n+1){
		dp[i]=(i*dp[i-1])%MOD;
	}
	vi a(k);
	loop(i,0,k){
		cin>>a[i];
	}
	if(k==0){
		cout<<dp[n]<<endl;
		return 0;
	}
	sort(a.begin(),a.end());
	vii b(k,vi(n));
	loop(i,0,k){
		int m=a[i];
		loop(j,0,n){
			b[i][j]=m/(ll)pow(2,n-1-j);
			m%=(ll)pow(2,n-1-j);
		}
	}
	loop(i,0,n){
		int flag=0;
		loop(j,0,k){
			if(flag==0){
				if(b[j][i]==1){
					flag=1;
				}
			}else{
				if(b[j][i]==0){
					cout<<0<<endl;
					return 0;
				}
			}
		}
	}
	ll ans=1;
	int cnt0=0;
	int cnt1=count(b[0].begin(),b[0].end(),1);
	ans*=dp[cnt1];
	loop(i,1,k){
		cnt0=cnt1;
		cnt1=count(b[i].begin(),b[i].end(),1);
		ans=(ans*dp[cnt1-cnt0])%MOD;
	}
	ans=(ans*dp[n-cnt1])%MOD;
	cout<<ans<<endl;
}
0