# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1004774 | 12345678 | Linear Garden (IOI08_linear_garden) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=1e6+5;
ll n, m, dp[3][nx], res, cnt, mx, mn;
string s;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m>>s;
dp[0][0]=dp[1][0]=dp[2][0]=1;
for (int i=1; i<=n; i++)
{
dp[0][i]=dp[1][i-1];
dp[1][i]=(dp[0][i-1]+dp[2][i-1])%m;
dp[2][i]=dp[1][i-1];
//cout<<"count "<<i<<' '<<dp[0][i]+dp[1][i]+dp[2][i]-2<<'\n';
}
for (int i=0; i<n; i++)
{
if (s[i]=='P')
{
ll tmp=cnt;
tmp++;
ll nmx=max(mx,tmp), nmn=mn, t=0;