Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int, int>
- #define pb(x) push_back(x)
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v) {
- for (auto x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvl(vector <ll> &v) {
- for (auto x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvv(vector <vector <int> > &v) {
- for (auto x : v) cv(x);
- cout << "\n";
- }
- void cvb(vector <bool> v) {
- for (bool x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvs(vector <string> v) {
- for (auto a : v) {
- cout << a << "\n";
- }
- }
- void cvp(vector <pii> a) {
- for (auto p : a) {
- cout << p.first << ' ' << p.second << "\n";
- }
- cout << "\n";
- }
- vector <vector <int> > dsk(8, vector <int> (8, 0));
- vector <int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
- bool ok(int i, int j) {
- return i >= 0 && i < 8 && j >= 0 && j < 8 && dsk[i][j] == 0;
- }
- int ans = 0;
- bool sh = 0;
- vector <pii> gd;
- void wrk(int x, int y) {
- if (sh) {
- cout << "x y = " << x << ' ' << y << "\n";
- }
- int i = x, j = y;
- if (sh) {
- cout << "x y = " << x << ' ' << y << "\n";
- cout << "start i j = " << i << ' ' << j << "\n";
- cout << "dsk\n";
- cvv(dsk);
- }
- //int id = -1;
- bool can = 1;
- pii start = {i, j};
- int cnt = 9;
- while (can) {
- if (sh) {
- cout << "i j = " << i << ' ' << j << "\n";
- }
- can = 0;
- for (int id = 0; id < 4; ++id) {
- if (ok(i + dx[id], j + dy[id])) {
- i += dx[id];
- j += dy[id];
- can = 1;
- dsk[i][j] = 1;
- cnt++;
- break;
- }
- }
- //can = 0;
- }
- if (cnt == 64) {
- ans++;
- gd.push_back(start);
- }
- if (sh) {
- cout << "cnt = " << cnt << "\n";
- cout << "dsk\n";
- cvv(dsk);
- }
- }
- int main() {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- for (int i =0; i < 8; ++i) {
- for (int j = 0; j < 8; ++j) {
- if (sh) {
- cout << "GO i j = " << i << ' ' << j << "\n";
- }
- dsk.assign(8, vector <int> (8, 0));
- for (int i = 1; i <= 4; ++i) {
- dsk[i][1] = 1;
- }
- for (int i = 3; i <= 6; ++i) {
- dsk[i][6] = 1;
- }
- if (dsk[i][j] == 0) {
- dsk[i][j] = 1;
- wrk(i, j);
- }
- }
- }
- cout << "ans = " << ans << "\n";
- cout << "good start = \n";
- cvp(gd);
- sh = 1;
- for (pii p: gd) {
- dsk.assign(8, vector <int> (8, 0));
- for (int i = 1; i <= 4; ++i) {
- dsk[i][1] = 1;
- }
- for (int i = 3; i <= 6; ++i) {
- dsk[i][6] = 1;
- }
- if (sh) {
- cout << "GO i j = " << p.first << ' ' << p.second << "\n";
- cout <<"dsk\n";
- cvv(dsk);
- }
- wrk(p.first, p.second);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement