# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
423518 | Bill_00 | Linear Garden (IOI08_linear_garden) | C++14 | 55 ms | 65540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define pp push
#define ff first
#define ss second
#define ll long long
#define mp make_pair
using namespace std;
long long u[1000005][5][5];
char s[2000000];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n,m;
cin >> n >> m;
for(int i=0;i<n;i++) cin >> s[i];
u[2][2][2]=1;
for(int i=1;i<=n;i++){
int o=0;
u[i][4][2]=(u[i-1][3][2]+u[i-1][3][1])%m;
u[i][4][1]=u[i-1][3][0];
u[i][3][2]=(u[i-1][2][2]+u[i-1][2][1])%m;
u[i][3][1]=(u[i-1][4][2]+u[i-1][2][0])%m;
u[i][3][0]=u[i-1][4][1];
u[i][2][1]=(u[i-1][2][2]+u[i-1][3][2])%m;
u[i][2][0]=(u[i-1][2][1]+u[i-1][3][1])%m;
}
int mx=0,mn=0;
long long ans=0;
for(int i=0;i<n-1;i++){
if(s[i]=='L'){
mx+=1;
mn=min(mn+1,0);
continue;
}
int mx_=mx+1;
int mn_=min(mn+1,0);
for(int j=0;j<=2-mx_;j++){
for(int k=0;k>=-2-mn_;k--){
ans=(ans+u[n-i-1][j+2][k+2])%m;
//cout << n-i-1 << ' ' << j << ' ' << k << ' ' << u[n-i-1][j][k] << endl;
}
}
mx=max(0,mx-1);
mn--;
}
if(s[n-1]=='P'){
if(mx!=2) ans++;
}
ans++;
cout << ans%m;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |