|
| 1 | +#pragma clang attribute push (__attribute__((no_sanitize("address","undefined"))), apply_to=function) |
| 2 | + |
| 3 | +const int mod = 1E9 + 7; |
| 4 | + |
| 5 | +int dp[2][3][4], ts; |
| 6 | +array<int, 2> t[1024]; |
| 7 | + |
| 8 | +ofstream out("user.out"); |
| 9 | + |
| 10 | +int main() { |
| 11 | + ios::sync_with_stdio(0), cin.tie(0); |
| 12 | + for (int n; cin >> n; ts++) t[ts] = {n, ts}; |
| 13 | + sort(t, t + ts, [](auto& x, auto& y) { return x[0] < y[0]; }); |
| 14 | + |
| 15 | + for (int a : {0, 1}) |
| 16 | + for (int l : {0, 1, 2}) |
| 17 | + dp[0][a][l] = 1; |
| 18 | + |
| 19 | + int ti = 0; |
| 20 | + for (int i = 1, lim = t[ts - 1][0]; i <= lim; i++) { |
| 21 | +#pragma unroll |
| 22 | + for (int a : {0, 1}) { |
| 23 | +#pragma unroll |
| 24 | + for (int l : {0, 1, 2}) { |
| 25 | + auto& ans = dp[i & 1][a][l]; |
| 26 | + ans = dp[~i & 1][a][0]; |
| 27 | + ans += dp[~i & 1][a + 1][0]; |
| 28 | + ans -= (ans >= mod) * mod; |
| 29 | + ans += dp[~i & 1][a][l + 1]; |
| 30 | + ans -= (ans >= mod) * mod; |
| 31 | + } |
| 32 | + } |
| 33 | + while (t[ti][0] == i) |
| 34 | + t[ti++][0] = dp[i & 1][0][0]; |
| 35 | + } |
| 36 | + sort(t, t + ts, [](auto& x, auto& y) { return x[1] < y[1]; }); |
| 37 | + for (int i = 0; i < ts; i++) |
| 38 | + out << t[i][0] << "\n"; |
| 39 | +} |
| 40 | + |
| 41 | +#define main main_ |
| 42 | + |
| 43 | +class Solution { |
| 44 | +public: |
| 45 | + int checkRecord(int n) { |
| 46 | + return 0; |
| 47 | + } |
| 48 | +}; |
| 49 | + |
| 50 | +#pragma clang attribute pop |
0 commit comments