제출 #734829

#제출 시각아이디문제언어결과실행 시간메모리
734829lucriLinear Garden (IOI08_linear_garden)C++17
95 / 100
53 ms25676 KiB
#include <bits/stdc++.h> using namespace std; long long n,m,pd[1000000][3],poza,sum,ans; char s[1000010]; void RezolvaRange(int b,int e) { sum=0; for(int i=1;i<=n;++i) { if(s[i-1]=='L') --sum; else if(s[i-1]=='P') ++sum; if(sum<b||sum>e) sum=1000000000000000000; pd[i][0]=pd[i][1]=pd[i][2]=0; if(sum<=e&&sum>=b+1&&s[i]=='P') ++pd[i][sum-b-1]; pd[i][0]+=pd[i-1][1]; pd[i][1]+=pd[i-1][0]+pd[i-1][2]; if(e-b>=2) pd[i][2]+=pd[i-1][1]; pd[i][0]%=m; pd[i][1]%=m; pd[i][2]%=m; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m>>s+1; ans=1; RezolvaRange(-2,0); ans+=pd[n][0]; ans+=pd[n][1]; ans+=pd[n][2]; RezolvaRange(-1,1); ans+=pd[n][0]; ans+=pd[n][1]; ans+=pd[n][2]; RezolvaRange(0,2); ans+=pd[n][0]; ans+=pd[n][1]; ans+=pd[n][2]; RezolvaRange(-1,0); ans-=pd[n][0]; ans-=pd[n][1]; RezolvaRange(0,1); ans-=pd[n][0]; ans-=pd[n][1]; cout<<(ans%m+m)%m; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

linear_garden.cpp: In function 'int main()':
linear_garden.cpp:33:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   33 |     cin>>n>>m>>s+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...