Submission #3981123
Source Code Expand
#define _GLIBCXX_DEBUG #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; int x[5][5]; bool used[26]; void numSet(vector<int> pos, vector<int> num){ int n = (int)pos.size(); rep (i, n){ int row = pos[i] / 5; int col = pos[i] % 5; x[row][col] = num[i]; } // end rep } void reStore(vector<int> pos){ int n = (int)pos.size(); rep (i, n){ int row = pos[i] / 5; int col = pos[i] % 5; x[row][col] = 0; } // end rep } bool is_ok(void){ rep (i, 5){ rep (j, 5){ if (i + 2 < 5){ if (x[i][j] < x[i+1][j] && x[i+1][j] < x[i+2][j]){ return false; } // end if if (x[i][j] > x[i+1][j] && x[i+1][j] > x[i+2][j]){ return false; } // end if } // end if if (j + 2 < 5){ if (x[i][j] < x[i][j+1] && x[i][j+1] < x[i][j+2]){ return false; } // end if if (x[i][j] > x[i][j+1] && x[i][j+1] > x[i][j+2]){ return false; } // end if } // end if } // end rep } // end rep return true; } void dispX(void){ rep (i, 5){ rep (j, 5){ cerr << setw(2) << x[i][j]; } // end rep cerr << endl; } // end rep } int main() { memset(used, false, sizeof(used)); ios_base::sync_with_stdio(0); cin.tie(0); rep (i, 5) rep (j, 5) cin >> x[i][j], used[x[i][j]] |= true; vector<int> unSetPos; unSetPos.clear(); vector<int> unSetNum; unSetNum.clear(); rep (i, 5) rep (j, 5){ if (x[i][j] == 0){ unSetPos.push_back(i * 5 + j); } // end if int curr = (i * 5 + j + 1); if (!used[curr]){ unSetNum.push_back(curr); } // end if } // end rep if ((int)unSetNum.size() > 8){ exit(-1); } // end if /* rep (i, (int)unSetNum.size()){ cerr << setw(2) << unSetNum[i] << ' '; } // end rep cerr << endl; */ int res = 0; do{ numSet(unSetPos, unSetNum); if (is_ok()){ ++res; // dispX(); // cerr << endl; } // end if reStore(unSetPos); }while(next_permutation(ALL(unSetNum))); cout << res << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 25個の整数 |
User | ty70 |
Language | C++14 (GCC 5.4.1) |
Score | 30 |
Code Size | 2131 Byte |
Status | RE |
Exec Time | 64 ms |
Memory | 256 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 | 2 ms | 256 KB |
sample-02.txt | AC | 64 ms | 256 KB |
sample-03.txt | AC | 2 ms | 256 KB |
sample-04.txt | AC | 1 ms | 256 KB |
test-1-01.txt | AC | 62 ms | 256 KB |
test-1-02.txt | AC | 2 ms | 256 KB |
test-1-03.txt | AC | 2 ms | 256 KB |
test-1-04.txt | AC | 9 ms | 256 KB |
test-1-05.txt | AC | 9 ms | 256 KB |
test-1-06.txt | AC | 61 ms | 256 KB |
test-1-07.txt | AC | 62 ms | 256 KB |
test-1-08.txt | AC | 61 ms | 256 KB |
test-1-09.txt | AC | 61 ms | 256 KB |
test-1-10.txt | AC | 1 ms | 256 KB |
test-1-11.txt | AC | 1 ms | 256 KB |
test-1-12.txt | AC | 60 ms | 256 KB |
test-1-13.txt | AC | 1 ms | 256 KB |
test-1-14.txt | AC | 62 ms | 256 KB |
test-1-15.txt | AC | 60 ms | 256 KB |
test-2-01.txt | RE | 1 ms | 256 KB |
test-2-02.txt | RE | 1 ms | 256 KB |
test-2-03.txt | RE | 1 ms | 256 KB |
test-2-04.txt | RE | 1 ms | 256 KB |
test-2-05.txt | RE | 1 ms | 256 KB |
test-2-06.txt | RE | 1 ms | 256 KB |
test-2-07.txt | RE | 1 ms | 256 KB |
test-2-08.txt | RE | 1 ms | 256 KB |
test-2-09.txt | RE | 1 ms | 256 KB |
test-2-10.txt | RE | 1 ms | 256 KB |