제출 #1242427

#제출 시각아이디문제언어결과실행 시간메모리
1242427hssaan_arif캥거루 (CEOI16_kangaroo)C++20
0 / 100
1 ms320 KiB
#include<bits/stdc++.h>
using namespace std;

#define endl "\n"
#define pb push_back
#define int long long

const int N = 1e3 + 5, M = 1e9 + 7 , LG = 20;

int n , dp[N][N][3] , s , t;

void solve(){
    cin >> n >> s >> t;
    if (s == 1 || t == 1){
        dp[1][1][1] = 1;
    }else{
        dp[1][1][0] = 1;
    }
    for (int i = 1 ; i <= n ; i++){
        for (int j = 1 ; j <= i ; j++){
            if (i + 1 == s || i + 1 == t){
                for (int k=0;k<2;k++){
                    dp[i+1][j+1][k+1] += dp[i][j][k];
                    dp[i+1][j-1][k+1] += dp[i][j][k];
                    continue;
                }
                
            }
            for (int k=0;k<3;k++){
                dp[i+1][j + 1][k] += dp[i][j][k] * (j + 1 - k);
                // dp[i+1][j] += dp[i][j] * 2 * j;
                dp[i+1][j - 1][k] += dp[i][j][k] * (j - 1);
            }
            
        }
    }
    cout << dp[n][n][2] << endl;
}

signed main(){
    freopen("kangaroo.in" , "r" , stdin);
    freopen("kangaroo.out" , "w" , stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int ts = 1;
    // cin >> ts;
    while(ts--){
        solve();
    }
}

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

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:41:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     freopen("kangaroo.in" , "r" , stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:42:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     freopen("kangaroo.out" , "w" , stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...