Submission #434040
Source Code Expand
#include <iostream> #include <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <cstdio> #include <string> #include <vector> #include <complex> #include <cstdlib> #include <cstring> #include <numeric> #include <sstream> #include <algorithm> #include <functional> #include <limits.h> #include <bitset> #include <tuple> #include <unordered_map> #define mp make_pair #define mt make_tuple #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; const int INF = 1 << 29; const double EPS = 1e-9; const ll MOD = 1000000007; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int board[6][6]; int check() { // cout << "-------------------" << endl; // for (int i = 0; i < 5; i++){ // for (int j = 0; j < 5; j++){ // cout << board[i][j] << " "; // } // cout << endl; // } // cout << "-------------------" << endl; for (int i = 0; i < 5; i++) { for (int j = 0; j < 3; j++) { if ((board[i][j] < board[i][j + 1] and board[i][j + 1] < board[i][j + 2]) or (board[i][j] > board[i][j + 1] and board[i][j + 1] > board[i][j + 2])) { return 0; } } } for (int j = 0; j < 5; j++) { for (int i = 0; i < 3; i++) { if ((board[i][j] < board[i + 1][j] and board[i + 1][j] < board[i + 2][j]) or (board[i][j] > board[i + 1][j] and board[i + 1][j] > board[i + 2][j])) { return 0; } } } return 1; } ll res; vector<pii> zero; bool cand[30]; void dfs(int cnt) { if (cnt == zero.size()) { res += check(); res %= MOD; return; } pii p = zero[cnt]; for (int i = 1; i <= 25; i++) { if (!cand[i]) { board[p.first][p.second] = i; cand[i] = true; dfs(cnt + 1); cand[i] = false; board[p.first][p.second] = 0; } } return; } int main() { // int sum = 0; for (int i = 0; i < 30; i++){ cand[i] = false; } res = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { cin >> board[i][j]; cand[board[i][j]] = true; if (board[i][j] == 0) { zero.push_back(mp(i, j)); } } } if (zero.size() >= 10) { return 0; } dfs(0); res %= MOD; cout << res << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 25個の整数 |
User | togatoga |
Language | C++11 (GCC 4.9.2) |
Score | 30 |
Code Size | 2497 Byte |
Status | WA |
Exec Time | 34 ms |
Memory | 920 KB |
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 30 / 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 | AC | 28 ms | 920 KB |
sample-02.txt | AC | 34 ms | 728 KB |
sample-03.txt | AC | 25 ms | 788 KB |
sample-04.txt | AC | 25 ms | 728 KB |
test-1-01.txt | AC | 30 ms | 804 KB |
test-1-02.txt | AC | 26 ms | 796 KB |
test-1-03.txt | AC | 27 ms | 796 KB |
test-1-04.txt | AC | 27 ms | 804 KB |
test-1-05.txt | AC | 26 ms | 728 KB |
test-1-06.txt | AC | 32 ms | 808 KB |
test-1-07.txt | AC | 31 ms | 840 KB |
test-1-08.txt | AC | 32 ms | 804 KB |
test-1-09.txt | AC | 31 ms | 916 KB |
test-1-10.txt | AC | 24 ms | 920 KB |
test-1-11.txt | AC | 23 ms | 920 KB |
test-1-12.txt | AC | 28 ms | 800 KB |
test-1-13.txt | AC | 27 ms | 920 KB |
test-1-14.txt | AC | 32 ms | 792 KB |
test-1-15.txt | AC | 30 ms | 796 KB |
test-2-01.txt | WA | 25 ms | 920 KB |
test-2-02.txt | WA | 26 ms | 804 KB |
test-2-03.txt | WA | 23 ms | 920 KB |
test-2-04.txt | WA | 25 ms | 672 KB |
test-2-05.txt | WA | 27 ms | 792 KB |
test-2-06.txt | WA | 26 ms | 808 KB |
test-2-07.txt | WA | 25 ms | 796 KB |
test-2-08.txt | WA | 25 ms | 796 KB |
test-2-09.txt | WA | 25 ms | 916 KB |
test-2-10.txt | WA | 24 ms | 916 KB |