Task: | Torni |
Sender: | Yytsi |
Submission time: | 2020-09-27 00:26:28 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | ACCEPTED | 41 |
#3 | ACCEPTED | 44 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.13 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.13 s | 2, 3 | details |
#3 | ACCEPTED | 0.13 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:22:8: warning: unused variable 'F_KU' [-Wunused-variable] ll F_KU = dp[h - 1][0][1]; ^~~~ input/code.cpp:23:8: warning: unused variable 'F_UK' [-Wunused-variable] ll F_UK = dp[h - 1][0][2]; ^~~~
Code
#include <bits/stdc++.h> using namespace std; using ll = long long; ll M = 1000000007LL; ll dp[1010101][2][4]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); dp[1][0][0] = 1; dp[1][0][3] = 1; dp[1][1][0] = 1; dp[1][1][1] = 1; dp[1][1][2] = 1; dp[1][1][3] = 1; for (int h = 2; h < 1010101; h++) { ll F_KK = dp[h - 1][0][0]; ll F_KU = dp[h - 1][0][1]; ll F_UK = dp[h - 1][0][2]; ll F_UU = dp[h - 1][0][3]; ll S_KK = dp[h - 1][1][0]; ll S_KU = dp[h - 1][1][1]; ll S_UK = dp[h - 1][1][2]; ll S_UU = dp[h - 1][1][3]; // flat // KK dp[h][0][0] = (dp[h][0][0] + F_KK + F_UU + S_KK) % M; // UU dp[h][0][3] = (dp[h][0][3] + F_KK + F_UU + S_KK) % M; // split // KK dp[h][1][0] = (dp[h][1][0] + F_KK + S_KK + S_UK + S_KU + S_UU) % M; // KU dp[h][1][1] = (dp[h][1][1] + F_KK + S_KK + S_UK + S_KU + S_UU) % M; // UK dp[h][1][2] = (dp[h][1][2] + F_KK + S_KK + S_UK + S_KU + S_UU) % M; // UU dp[h][1][3] = (dp[h][1][3] + F_KK + S_KK + S_UK + S_KU + S_UU) % M; } int t; cin>>t; while (t--) { int n; cin>>n; ll res = (dp[n][0][0] + dp[n][1][0]) % M; if (res < 0) res += M; cout<<res<<"\n"; } }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
10 1 2 3 4 ... |
correct output |
---|
2 8 34 148 650 ... |
user output |
---|
2 8 34 148 650 ... |
Test 2
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 1 2 3 4 ... |
correct output |
---|
2 8 34 148 650 ... |
user output |
---|
2 8 34 148 650 ... Truncated |
Test 3
Group: 3
Verdict: ACCEPTED
input |
---|
100 996306 650655 896240 821967 ... |
correct output |
---|
87350005 606189151 122595036 193572715 227926807 ... |
user output |
---|
87350005 606189151 122595036 193572715 227926807 ... Truncated |