Submission #2308088
Source Code Expand
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);++i) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair<int, int> P; const ll MOD = (ll)1e9 + 7LL; int x[25], pos[25]; vector<int> unused; ll dp[1<<25]; void calc(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() { memset(x, 0, sizeof(x)); memset(pos, -1, sizeof(pos)); memset(dp, 0LL, sizeof(dp)); unused.clear(); ios_base::sync_with_stdio(0); cin.tie(0); rep (i, 25){ cin >> x[i]; --x[i]; if (x[i] < 0){ unused.push_back(i); }else{ pos[x[i]] = i; } // end rep } // end rep dp[0] = 1LL; for (int i = 0; i < 1<<25; ++i){ if (dp[i] == 0LL) continue; int bit = __builtin_popcount(i); if (pos[bit] >= 0){ calc(i, pos[bit]); }else{ for (int j = 0; j < (int)unused.size(); ++j){ calc(i, unused[j]); } // end for } // end if } // end for ll res = dp[(1<<25) - 1]; cout << res << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 25個の整数 |
User | ty70 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1213 Byte |
Status | MLE |
Exec Time | 202 ms |
Memory | 262400 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 | 135 ms | 262400 KB |
sample-02.txt | MLE | 140 ms | 262400 KB |
sample-03.txt | MLE | 132 ms | 262400 KB |
sample-04.txt | MLE | 133 ms | 262400 KB |
test-1-01.txt | MLE | 134 ms | 262400 KB |
test-1-02.txt | MLE | 132 ms | 262400 KB |
test-1-03.txt | MLE | 134 ms | 262400 KB |
test-1-04.txt | MLE | 134 ms | 262400 KB |
test-1-05.txt | MLE | 133 ms | 262400 KB |
test-1-06.txt | MLE | 132 ms | 262400 KB |
test-1-07.txt | MLE | 132 ms | 262400 KB |
test-1-08.txt | MLE | 133 ms | 262400 KB |
test-1-09.txt | MLE | 132 ms | 262400 KB |
test-1-10.txt | MLE | 132 ms | 262400 KB |
test-1-11.txt | MLE | 132 ms | 262400 KB |
test-1-12.txt | MLE | 132 ms | 262400 KB |
test-1-13.txt | MLE | 132 ms | 262400 KB |
test-1-14.txt | MLE | 132 ms | 262400 KB |
test-1-15.txt | MLE | 133 ms | 262400 KB |
test-2-01.txt | MLE | 134 ms | 262400 KB |
test-2-02.txt | MLE | 132 ms | 262400 KB |
test-2-03.txt | MLE | 132 ms | 262400 KB |
test-2-04.txt | MLE | 134 ms | 262400 KB |
test-2-05.txt | MLE | 138 ms | 262400 KB |
test-2-06.txt | MLE | 180 ms | 262400 KB |
test-2-07.txt | MLE | 162 ms | 262400 KB |
test-2-08.txt | MLE | 178 ms | 262400 KB |
test-2-09.txt | MLE | 169 ms | 262400 KB |
test-2-10.txt | MLE | 202 ms | 262400 KB |