Submission #2075076
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = (ll)1e9 + 7; vector<int> a(25), pos(25, -1), none; vector<ll> dp(1 << 25); void f(int s, int t) { int y = t / 5, x = t % 5; if (s & (1 << t)) return; if (y > 0 && y < 4 && ((s >> (t - 5)) ^ (s >> (t + 5))) & 1) return; if (x > 0 && x < 4 && ((s >> (t - 1)) ^ (s >> (t + 1))) & 1) return; (dp[s | (1 << t)] += dp[s]) %= mod; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); for (int i = 0; i < 25; i++) { cin >> a[i]; a[i]--; if (a[i] < 0) none.push_back(i); else pos[a[i]] = i; } dp[0] = 1; for (int i = 0; i < 1 << 25; i++) { if (!dp[i]) continue; int bit = __builtin_popcount(i); if (pos[bit] >= 0) { f(i, pos[bit]); } else { for (auto& j : none) { f(i, j); } } } cout << dp[(1 << 25) - 1] << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 25個の整数 |
User | legosuke |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 949 Byte |
Status | MLE |
Exec Time | 157 ms |
Memory | 262528 KB |
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 30 | 0 / 70 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
Subtask1 | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, test-1-01.txt, test-1-02.txt, test-1-03.txt, test-1-04.txt, test-1-05.txt, test-1-06.txt, test-1-07.txt, test-1-08.txt, test-1-09.txt, test-1-10.txt, test-1-11.txt, test-1-12.txt, test-1-13.txt, test-1-14.txt, test-1-15.txt |
Subtask2 | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, test-1-01.txt, test-1-02.txt, test-1-03.txt, test-1-04.txt, test-1-05.txt, test-1-06.txt, test-1-07.txt, test-1-08.txt, test-1-09.txt, test-1-10.txt, test-1-11.txt, test-1-12.txt, test-1-13.txt, test-1-14.txt, test-1-15.txt, test-2-01.txt, test-2-02.txt, test-2-03.txt, test-2-04.txt, test-2-05.txt, test-2-06.txt, test-2-07.txt, test-2-08.txt, test-2-09.txt, test-2-10.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample-01.txt | MLE | 92 ms | 262400 KB |
sample-02.txt | MLE | 92 ms | 262400 KB |
sample-03.txt | MLE | 92 ms | 262400 KB |
sample-04.txt | MLE | 92 ms | 262400 KB |
test-1-01.txt | MLE | 92 ms | 262400 KB |
test-1-02.txt | MLE | 92 ms | 262400 KB |
test-1-03.txt | MLE | 92 ms | 262400 KB |
test-1-04.txt | MLE | 92 ms | 262400 KB |
test-1-05.txt | MLE | 92 ms | 262400 KB |
test-1-06.txt | MLE | 92 ms | 262400 KB |
test-1-07.txt | MLE | 92 ms | 262400 KB |
test-1-08.txt | MLE | 92 ms | 262400 KB |
test-1-09.txt | MLE | 93 ms | 262400 KB |
test-1-10.txt | MLE | 91 ms | 262400 KB |
test-1-11.txt | MLE | 92 ms | 262400 KB |
test-1-12.txt | MLE | 92 ms | 262400 KB |
test-1-13.txt | MLE | 92 ms | 262400 KB |
test-1-14.txt | MLE | 92 ms | 262400 KB |
test-1-15.txt | MLE | 92 ms | 262400 KB |
test-2-01.txt | MLE | 92 ms | 262400 KB |
test-2-02.txt | MLE | 92 ms | 262400 KB |
test-2-03.txt | MLE | 92 ms | 262400 KB |
test-2-04.txt | MLE | 93 ms | 262400 KB |
test-2-05.txt | MLE | 97 ms | 262400 KB |
test-2-06.txt | MLE | 136 ms | 262400 KB |
test-2-07.txt | MLE | 120 ms | 262400 KB |
test-2-08.txt | MLE | 135 ms | 262528 KB |
test-2-09.txt | MLE | 125 ms | 262400 KB |
test-2-10.txt | MLE | 157 ms | 262400 KB |