Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ve vector
- ve<int> Max = { 40, 40, 10 };
- int A = 0;
- int B = 1;
- int C = 2;
- map<ve<int>, bool> Win;
- bool f(ve<int>& State) {
- bool win;
- ve<int> StateNew;
- if (Win.find(State) == Win.end()) {
- win = false;
- for (int i = 0; i < State.size(); i++) {
- for (int k = 1; k <= State[i]; k++) {
- StateNew = State;
- StateNew[i] -= k;
- if (!f(StateNew)) win = true;
- for (int j = 0; j < i; j++) {
- StateNew = State;
- StateNew[i] -= k;
- StateNew[j] += k;
- if (!f(StateNew)) win = true;
- }
- }
- }
- Win[State] = win;
- }
- return Win[State];
- }
- int main() {
- ve<int> State;
- State = Max;
- for (int k = 0; k <= Max[C]; k++) {
- State[C] = k;
- cout << k << endl;
- cout << endl;
- for (int i = 0; i <= Max[A]; i++) {
- State[A] = i;
- for (int j = 0; j <= Max[B]; j++) {
- State[B] = j;
- if (f(State)) cout << ". ";
- else cout << "X ";
- }
- cout << endl;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment