Submission #746181

#TimeUsernameProblemLanguageResultExecution timeMemory
746181turbatLinear Garden (IOI08_linear_garden)C++14
2 / 100
81 ms65536 KiB
#include <iostream> using namespace std; #define N 1000005 int n, m, dp[N][7][7]; int main() { string garden; cin >> n >> m >> garden; for (int pre = 1; pre <= 5; pre++) { dp[0][pre][pre] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= 5; j++) { dp[i][j][pre] = (dp[i - 1][j - 1][pre] + dp[i - 1][j + 1][pre]) % m; } } int ans = 1; } int cnt = 3, ans = 1; for (int i = 1; i <= n; i++) { cnt += (garden[i - 1] == 'P' ? 1 : -1); if (garden[i - 1] == 'P') { ans += dp[n - i][1][cnt - 1] + dp[n - i][2][cnt - 1] + dp[n - i][3][cnt - 1] + dp[n - i][4][cnt - 1] + dp[n - i][5][cnt - 1]; ans %= m; } } cout << ans; }

Compilation message (stderr)

linear_garden.cpp: In function 'int main()':
linear_garden.cpp:19:13: warning: unused variable 'ans' [-Wunused-variable]
   19 |         int ans = 1;
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...