結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー |
|
提出日時 | 2021-11-17 20:12:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,056 bytes |
コンパイル時間 | 910 ms |
コンパイル使用メモリ | 97,028 KB |
実行使用メモリ | 13,768 KB |
最終ジャッジ日時 | 2024-12-24 00:45:15 |
合計ジャッジ時間 | 33,468 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 WA * 32 TLE * 10 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <stdio.h> #include <queue> #include <deque> #include <cstdio> #include <set> #include <map> #include <bitset> #include <stack> #include <cctype> using namespace std; int main() { int n, k; long long a[66]; cin >> n >> k; for (int i = 1; i <= k; i++) { cin >> a[i]; if (a[i] == 0) { i--; } } a[0] = 0, a[k + 1] = (1 << n) - 1; sort(a, a + k); long long ans = 1; for (int i = 1; i <= k + 1; i++) { long long co = 0; for (int j = 0; j < n; j++) { if (!(a[i] & (1 << j)) && (a[i - 1] & (1 << j))) { cout << 0 << endl; return 0; } if ((a[i] & (1 << j)) && !(a[i - 1] & (1 << j))) { co++; } } for (long long j = co; j > 0; j--) { ans *= j; ans %= 1000000007; } } cout << ans << endl; return 0; }