이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
long long n , m , in [202] , de [202] , inmx [202] , demx [202] , mod = 1e9 + 7;
long long dp [202][202][31];
long long f ( int x , int y , int last )
{
if ( x == n + 1 ) return 1;
if ( dp [x][y][last] != -1 ) return dp [x][y][last];
long long ans = 0;
ans = ( ans = f ( x + 1 , y , last ) ) % mod;
int aa = 1 , bb = 1;
for ( int j = y ; j < x ; j ++ )
{
if ( demx [j] >= x ) aa = 0;
if ( inmx [j] >= x ) bb = 0;
}
if ( aa )
{
for ( int i = last + 1 ; i < 26 ; i ++ ) ans = ( ans + f ( x + 1 , x , i ) ) % mod;
}
if ( bb )
{
for ( int i = 0 ; i < last ; i ++ ) ans = ( ans + f ( x + 1 , x , i ) ) % mod;
}
return dp [x][y][last] = ans;
}
int main()
{
memset ( dp , -1 , sizeof dp );
cin >> n >> m;
for ( int i = 1 ; i <= n ; i ++ )
{
in [i] = 1e9;
de [i] = 1e9;
}
for ( int i = 0 ; i < m ; i ++ )
{
long long x , y;
cin >> x >> y;
if ( x < y )
{
de [x] = min ( de [x] , y );
demx [x] = max ( demx [x] , y );
}
if ( x > y )
{
in [y] = min ( in [y] , x );
inmx [y] = max ( inmx [y] , x );
}
}
cout << f ( 1 , 0 , 0 );
}
컴파일 시 표준 에러 (stderr) 메시지
misspelling.cpp: In function 'long long int f(int, int, int)':
misspelling.cpp:10:9: warning: operation on 'ans' may be undefined [-Wsequence-point]
10 | ans = ( ans = f ( x + 1 , y , last ) ) % mod;
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |