<p>In the &quot;100 game&quot; two players take turns adding, to a running total, any integer from <code>1</code> to <code>10</code>. The player who first causes the running total to <strong>reach or exceed</strong> 100 wins.</p>

<p>What if we change the game so that players <strong>cannot</strong> re-use integers?</p>

<p>For example, two players might take turns drawing from a common pool of numbers from 1 to 15 without replacement until they reach a total &gt;= 100.</p>

<p>Given two integers <code>maxChoosableInteger</code> and <code>desiredTotal</code>, return <code>true</code> if the first player to move can force a win, otherwise, return <code>false</code>. Assume both players play <strong>optimally</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> maxChoosableInteger = 10, desiredTotal = 11
<strong>Output:</strong> false
<strong>Explanation:</strong>
No matter which integer the first player choose, the first player will lose.
The first player can choose an integer from 1 up to 10.
If the first player choose 1, the second player can only choose integers from 2 up to 10.
The second player will win by choosing 10 and get a total = 11, which is &gt;= desiredTotal.
Same with other integers chosen by the first player, the second player will always win.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> maxChoosableInteger = 10, desiredTotal = 0
<strong>Output:</strong> true
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> maxChoosableInteger = 10, desiredTotal = 1
<strong>Output:</strong> true
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= maxChoosableInteger &lt;= 20</code></li>
	<li><code>0 &lt;= desiredTotal &lt;= 300</code></li>
</ul>

class Solution {
public:
    //bool canIWin(int maxChoosableInteger, int desiredTotal) {
/*int print0(vector<int> b,int c,int e){
    int temp0=1;
    int temp12=0;
    for(int temp2=0;temp2<b.size();temp2++){
        if(b[temp2]!=1){
            c=c+temp2+1;
            b[temp2]=1;
            if(c>=e){
                temp0=0;
                break;
            }
            temp12=temp12 || print0(b,c,e);
            c=c-temp2-1;
            b[temp2]=0;
        }
    }
    if(temp0==0){
        return temp0;
    }
    if(temp12==1){
        temp0=0;
    }
    return temp0;
}
bool canIWin(int b,int c){
    vector<int> e;
    for(int temp0=0;temp0<b;temp0++){
        e.push_back(0);
    }
    int temp0=0;
    int temp2=c;
    int temp12=0;
    temp12=print0(e,temp0,temp2);
    int temp18=0;
    if(temp12==1){
        temp18=0;
    }
    else if(temp12==0){
        temp18=1;
    }
    return temp18;
    }*/
    int print0(string &b,int c,int e,unordered_map<string,pair<int,int>> &temp28){
    if(temp28[b].first==1){
        return temp28[b].second;
    }
    int temp0=1;
    int temp2=0;
    //pair<int,int> temp2;
    //pair<int,int> temp48;
    //temp2.first=0;
    //temp2.second=0;
    for(int temp18=0;temp18<b.size();temp18++){
        if(b[temp18]!='1'){
           c=c+temp18+1;
           b[temp18]='1';
            if(c>=e){
            temp0=0;
            b[temp18]='0';
            c=c-temp18-1;
            break;
           }
         temp2=temp2 || print0(b,c,e,temp28);
            //temp48=print0(b,c,e,temp28);
            //if(temp2.first<=temp18+temp48.second){
            //    temp2.first=temp18+temp48.second;
            //    temp2.second=temp48.first;
            //}
         c=c-temp18-1;
         b[temp18]='0';
        }
    }
    if(temp0==0){
        return temp0;
    }
    if(temp2==1){
        temp0=0;
    }
    temp28[b].first=1;
    temp28[b].second=temp0;
    //temp28[b].first=1;
    //temp28[b].second=temp2;
    return temp0;
}
bool canIWin(int b,int c){
    string e="";
    for(int temp0=0;temp0<b;temp0++){
        e.push_back('0');
    }
    int temp0=0;
    int temp2=0;
    unordered_map<string,pair<int,int>> temp18;
    int temp12=c;
    int temp72=0;
    for(int temp78=0;temp78<b;temp78++){
        temp72=temp72+temp78+1;
    }
    if(temp72<c){
        return 0;
    }
    temp2=print0(e,temp0,temp12,temp18);
    int temp48=0;
    if(temp2==0){
        temp48=1;
    }
    else if(temp2==1){
        temp48=0;
    }
    return temp48;
}
};
204447