# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
230005 | CaroLinda | Linear Garden (IOI08_linear_garden) | C++14 | 74 ms | 65540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define mkt make_tuple
#define debug printf
#define all(x) x.begin(),x.end()
#define lp(i,a,b) for(int i = a ; i< b ; i++)
#define ss second
#define ff first
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mk make_pair
const int MAXN = 1e6+10 ;
using namespace std ;
int N , M ;
char str[MAXN] ;
ll dp[MAXN][5][5] ;
int main()
{
scanf("%d %d %s", &N , &M , str ) ;
for(int i = 0 ; i < 5 ; i++ )
for(int j = 0 ; j < 5 ; j++ ) dp[0][i][j] = 1LL ;
for(int tam = 1 ; tam <= N ; tam ++ )
for(int l = 0 ; l < 5 ; l++ )
for(int p = 0 ; p < 5 ; p++ )
{
if( l+1 <= 4 && p-1 >= 0 )
dp[tam][l][p] = dp[tam-1][ max(l+1,3) ][p-1] ;
if( l-1 >= 0 && p+1 <= 4 )
( dp[tam][l][p] += dp[tam-1][l-1][ max(p+1,3) ] ) %= M ;
}
int cnt = 0 , l = 2 , p = 2;
for(int i = 0 ; i < N ; i++ )
{
int lef = N - i - 1 ;
if( str[i] == 'P' )
if( l+1 <= 4 && p-1 >= 0 ) ( cnt += dp[lef][ max(l+1,3) ][p-1] ) %= M ;
if(str[i] == 'L') l = max(l+1, 3) , p -- ;
else p = max(p+1, 3) , l-- ;
}
printf("%d\n" , (cnt+1)%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... |