제출 #834297

#제출 시각아이디문제언어결과실행 시간메모리
834297Gondozu캥거루 (CEOI16_kangaroo)C++14
0 / 100
2 ms340 KiB
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define Gondozu ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vpi = vector <pair<int, int>>;
using vvi = vector <vector<int>>;

const int OO = 1e9 + 5;
const int N = 2e3 + 5, MOD = 1e9+7;

int n, s, e;
ll dp[N][N];

ll add(ll a, ll b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}
ll mul(ll a, ll b) { return a * b % MOD; }


void TC()
{
    cin >> n >> s >> e;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            ll &cur = dp[i][j];
            if(i == 1){
                cur = j == 1;
                continue;
            }
            if(i == s || i == e){
                cur = dp[i-1][j-1]; // new comp
                if(j > (i == max(e,s)) || i == n)
                    cur = add(cur, dp[i-1][j]); // append
                continue;
            }

            cur = mul(dp[i-1][j-1], j - (i>s) - (i>e)); // new
            if(j > 2 || (j == 2 && i < max(s,e)) || i == n)
                cur = add(cur, mul(dp[i-1][j+1], j)); // merge
        }
    }
    cout << dp[n][1];
}

int32_t main() {
    freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout);
    Gondozu
    int t = 1;
//    cin >> t;
    while (t--) {
        TC();
        cout << '\n';
    }
    return 0;
}

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

kangaroo.cpp: In function 'int32_t main()':
kangaroo.cpp:55:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:55:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     freopen("kangaroo.in", "r", stdin); 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...