Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
//#include
#include
using namespace std; int main() { ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; unordered_map
mapa; vector
v(k); for(int i = 0; i < k; i++) { cin >> v[i]; mapa[v[i]] = true; } long long res = 0; if(n == 6) { for(int a = 0; a < k; a++) { for(int b = a + 1; b < k; b++) { for(int c = b + 1; c < k; c++) { for(int d = c + 1; d < k; d++) { for(int e = d + 1; e < k; e++) { for(int f = e + 1; f < k; f++) { vector
crossword(n); crossword[0] = v[a]; crossword[1] = v[b]; crossword[2] = v[c]; crossword[3] = v[d]; crossword[4] = v[e]; crossword[5] = v[f]; int cnt = 0; for(int i = 0; i < n; i++) { string word = ""; for(int j = 0; j < n; j++) { word += crossword[i][j]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { //// for(int y = 0; y < n; y++) { //// cout << crossword[x][y]; //// } //// cout << endl; //// } break; } word = ""; for(int j = n - 1; j >= 0; j--) { word += crossword[i][j]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } word = ""; for(int j = 0; j < n; j++) { word += crossword[j][i]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } word = ""; for(int j = n - 1; j >= 0; j--) { word += crossword[j][i]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } } } } } } } } } else if(n == 3) { for(int a = 0; a < k; a++) { for(int b = a + 1; b < k; b++) { for(int c = b + 1; c < k; c++) { vector
crossword(n); crossword[0] = v[a]; crossword[1] = v[b]; crossword[2] = v[c]; int cnt = 0; for(int i = 0; i < n; i++) { string word = ""; for(int j = 0; j < n; j++) { word += crossword[i][j]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { //// for(int y = 0; y < n; y++) { //// cout << crossword[x][y]; //// } //// cout << endl; //// } break; } word = ""; for(int j = n - 1; j >= 0; j--) { word += crossword[i][j]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } word = ""; for(int j = 0; j < n; j++) { word += crossword[j][i]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } word = ""; for(int j = n - 1; j >= 0; j--) { word += crossword[j][i]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } } } } } } else if(n == 5) { for(int a = 0; a < k; a++) { for(int b = a + 1; b < k; b++) { for(int c = b + 1; c < k; c++) { for(int d = c + 1; d < k; d++) { for(int e = d + 1; e < k; e++) { vector
crossword(n); crossword[0] = v[a]; crossword[1] = v[b]; crossword[2] = v[c]; crossword[3] = v[d]; crossword[4] = v[e]; int cnt = 0; for(int i = 0; i < n; i++) { string word = ""; for(int j = 0; j < n; j++) { word += crossword[i][j]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { //// for(int y = 0; y < n; y++) { //// cout << crossword[x][y]; //// } //// cout << endl; //// } break; } word = ""; for(int j = n - 1; j >= 0; j--) { word += crossword[i][j]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } word = ""; for(int j = 0; j < n; j++) { word += crossword[j][i]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } word = ""; for(int j = n - 1; j >= 0; j--) { word += crossword[j][i]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } } } } } } } for(int a = 0; a < k; a++) { for(int b = a + 1; b < k; b++) { for(int c = b + 1; c < k; c++) { for(int d = c + 1; d < k; d++) { for(int e = d + 1; e < k; e++) { vector
crossword(n, "wwwww"); for(int j = 0; j < n; j++) { crossword[0][j] = v[a][j]; } for(int j = 0; j < n; j++) { crossword[1][j] = v[b][j]; } for(int j = 0; j < n; j++) { crossword[2][j] = v[c][j]; } for(int j = 0; j < n; j++) { crossword[3][j] = v[d][j]; } for(int j = 0; j < n; j++) { crossword[4][j] = v[e][j]; } int cnt = 0; for(int i = 0; i < n; i++) { string word = ""; for(int j = 0; j < n; j++) { word += crossword[i][j]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { //// for(int y = 0; y < n; y++) { //// cout << crossword[x][y]; //// } //// cout << endl; //// } break; } word = ""; for(int j = n - 1; j >= 0; j--) { word += crossword[i][j]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } word = ""; for(int j = 0; j < n; j++) { word += crossword[j][i]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } word = ""; for(int j = n - 1; j >= 0; j--) { word += crossword[j][i]; } if(mapa[word]) { cnt++; } if(cnt >= 2 * n) { res++; // for(int x = 0; x < n; x++) { // for(int y = 0; y < n; y++) { // cout << crossword[x][y]; // } // cout << endl; // } break; } } } } } } } } cout << res << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)