Submission #1758700
Source Code Expand
#include <bits/stdc++.h> typedef long long int ll; #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define EREP(i, n) for (int i = (n - 1); i >= 0; --i) #define mod 1000000007 #define INF 93193111451418101 #define MIN -93193111451418101 //#define INF 931931114518101 using namespace std; typedef pair<ll, ll> P; template <typename T> void fill_all(T &arr, const T &v) { arr = v; } template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) { for (auto &i : arr) { fill_all(i, v); } } #define yo 100001 //------------------変数-----------------------// ll grid[26]; int dp[1 << 25]; map<ll, ll> selected; //-------------------関数----------------------// int main() { REP(i, 25) { cin >> grid[i]; if (grid[i]) { selected[grid[i]] = i + 1; } } dp[0] = 1; REP(i, (1 << 25) - 1) { if (!dp[i]) continue; ll flagcnt = __builtin_popcount(i) + 1; //どの整数まで数えたか if (selected[flagcnt]) { ll x = selected[flagcnt] - 1; ll y = x / 5; x %= 5; ll place = selected[flagcnt] - 1; if (x > 0 && x < 4 && ((i >> (place - 1)) ^ (i >> (place + 1))) & 1) continue; if (y > 0 && y < 4 && ((i >> (place - 5)) ^ (i >> (place + 5))) & 1) continue; (dp[i | (1 << place)] += dp[i]) %= mod; } else { REP(j, 25) { if (grid[j] || i >> j & 1) { continue; } ll x = j; ll y = x / 5; x %= 5; ll place = j; if (x > 0 && x < 4 && ((i >> (place - 1)) ^ (i >> (place + 1))) & 1) continue; if (y > 0 && y < 4 && ((i >> (place - 5)) ^ (i >> (place + 5))) & 1) continue; (dp[i | (1 << place)] += dp[i]) %= mod; } } } cout << dp[(1 << 25) - 1]; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 25個の整数 |
User | keidaroo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1890 Byte |
Status | WA |
Exec Time | 98 ms |
Memory | 113280 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 | WA | 26 ms | 12544 KB |
sample-02.txt | WA | 27 ms | 20736 KB |
sample-03.txt | WA | 23 ms | 256 KB |
sample-04.txt | WA | 26 ms | 12544 KB |
test-1-01.txt | WA | 26 ms | 12544 KB |
test-1-02.txt | WA | 26 ms | 14592 KB |
test-1-03.txt | WA | 26 ms | 16640 KB |
test-1-04.txt | WA | 37 ms | 69888 KB |
test-1-05.txt | WA | 26 ms | 16640 KB |
test-1-06.txt | WA | 27 ms | 16640 KB |
test-1-07.txt | WA | 24 ms | 2304 KB |
test-1-08.txt | WA | 31 ms | 39168 KB |
test-1-09.txt | WA | 26 ms | 12544 KB |
test-1-10.txt | WA | 26 ms | 12544 KB |
test-1-11.txt | WA | 26 ms | 12544 KB |
test-1-12.txt | WA | 27 ms | 18688 KB |
test-1-13.txt | WA | 26 ms | 12544 KB |
test-1-14.txt | WA | 27 ms | 18688 KB |
test-1-15.txt | WA | 28 ms | 24832 KB |
test-2-01.txt | WA | 31 ms | 33024 KB |
test-2-02.txt | WA | 29 ms | 24960 KB |
test-2-03.txt | WA | 29 ms | 30976 KB |
test-2-04.txt | WA | 49 ms | 113152 KB |
test-2-05.txt | WA | 43 ms | 70272 KB |
test-2-06.txt | WA | 78 ms | 68224 KB |
test-2-07.txt | WA | 68 ms | 92416 KB |
test-2-08.txt | WA | 85 ms | 113280 KB |
test-2-09.txt | WA | 71 ms | 74624 KB |
test-2-10.txt | WA | 98 ms | 78336 KB |