<p>An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:</p>

<ul>
	<li><code>&#39;A&#39;</code>: Absent.</li>
	<li><code>&#39;L&#39;</code>: Late.</li>
	<li><code>&#39;P&#39;</code>: Present.</li>
</ul>

<p>Any student is eligible for an attendance award if they meet <strong>both</strong> of the following criteria:</p>

<ul>
	<li>The student was absent (<code>&#39;A&#39;</code>) for <strong>strictly</strong> fewer than 2 days <strong>total</strong>.</li>
	<li>The student was <strong>never</strong> late (<code>&#39;L&#39;</code>) for 3 or more <strong>consecutive</strong> days.</li>
</ul>

<p>Given an integer <code>n</code>, return <em>the <strong>number</strong> of possible attendance records of length</em> <code>n</code><em> that make a student eligible for an attendance award. The answer may be very large, so return it <strong>modulo</strong> </em><code>10<sup>9</sup> + 7</code>.</p>

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

<pre>
<strong>Input:</strong> n = 2
<strong>Output:</strong> 8
<strong>Explanation:</strong> There are 8 records with length 2 that are eligible for an award:
&quot;PP&quot;, &quot;AP&quot;, &quot;PA&quot;, &quot;LP&quot;, &quot;PL&quot;, &quot;AL&quot;, &quot;LA&quot;, &quot;LL&quot;
Only &quot;AA&quot; is not eligible because there are 2 absences (there need to be fewer than 2).
</pre>

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

<pre>
<strong>Input:</strong> n = 1
<strong>Output:</strong> 3
</pre>

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

<pre>
<strong>Input:</strong> n = 10101
<strong>Output:</strong> 183236316
</pre>

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

<ul>
	<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution {
public:
    int checkRecord(int n) {
        vector<long>dp00(n+1,0);
        vector<long>dp01(n+1,0);
        vector<long>dp02(n+1,0);
        vector<long>dp10(n+1,0);
        vector<long>dp11(n+1,0);
        vector<long>dp12(n+1,0);
        dp00[0] = 1;
        long M = 1e9+7;

        for (int i = 1; i <= n; i++) {
            dp00[i] = (dp00[i-1] + dp01[i-1] + dp02[i-1]) % M;
            dp01[i] = dp00[i-1];
            dp02[i] = dp01[i-1];
            dp10[i] = (dp00[i-1] + dp01[i-1] + dp02[i-1] + dp10[i-1] + dp11[i-1] + dp12[i-1]) % M;
            dp11[i] = dp10[i-1];
            dp12[i] = dp11[i-1];
        }
        return (dp00[n]+dp01[n]+dp02[n]+dp10[n]+dp11[n]+dp12[n])%M;
    }
};



/*
=== 思路 ===
0. 一個學生出勤紀錄包含'A'/'L'/'P'
   => 若學生是eligible
      => 總共A必須<2, L不能連續3天以上(含)
   => 回傳所有可能長度為n的出勤紀錄之"數量"
      => mod 1e9+7

1. dpA/L/P[i]代表 長度為i並以A/L/P結尾之可能性
   => [卡] 如何考慮到A數量與L連續數量
      => 先拆開兩個條件去解, 再把兩種狀態合併起來
   dp00[i]: for s[0:i] A appeared 0 times, ending with 0Ls
   dp01[i]: for s[0:i] A appeared 0 times, ending with 1Ls
   dp02[i]: for s[0:i] A appeared 0 times, ending with 2Ls
   dp10[i]: for s[0:i] A appeared 1 times, ending with 0Ls
   dp11[i]: for s[0:i] A appeared 1 times, ending with 1Ls
   dp12[i]: for s[0:i] A appeared 1 times, ending with 2Ls

   => 再去做狀態轉移
   
=== 做法 ===
1. 
*/
113728