제출 #1294006

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

#define all(v) v.begin(), v.end()
#define yes cout << "Yes" << "\n"
#define no cout << "No" << "\n"
#define pb push_back
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef vector <pii> vii;
typedef vector <ll> vi;

template<typename T>
void read(vector<T>& v) {
    for (auto &x : v) cin >> x;
}

template<typename T>
void print(const vector<T>& v) {
    for (auto &x : v) cout << x << ' ';
    cout << "\n";
}
int f, s;
int n;
const ll MAX = 1e6 + 5;
const ll MOD = 1e9 + 7;
int rcs(int a, int b, map <int, int> mp) {
    map <int, int> mp1 = mp;
    mp1[a]++;
    bool ok = false;
    if (a < b) {
        vi c;
        for (int i = a + 1; i <= n; i++) {
            if (mp1[i] == 0 && i != f && i != s) {
                c.pb(i);
            }
        }
        int say = 0;
        if (c.size() == 0 && a < f) {
            return 1;
        }
        else if (c.size() == 0) {
            return 0;
        } 
        else {
            for (auto x : c) {
                say += rcs(x, a, mp1);
                say = say % MOD;
            }
        }
        return say;
    }
    else {
        vi c;
        for (int i = a - 1; i >= 1; i--) {
            if (mp1[i] == 0 && i != f && i != s) {
                c.pb(i);
            }
        }
        int say = 0;
        if (c.size() == 0 && a > f) {
            return 1;
        }
        else if (c.size() == 0) {
            return 0;
        } 
        else {
            for (auto x : c) {
                say += rcs(x, a, mp1);
                say = say % MOD;
            }
        }
        return say;
    }
}
void solve() {
    cin >> n >> s >> f;
    int cem = 0;
    map <int, int> mp;
    mp[s]++;
    for (int i = 1; i <= n; i++) {
        if (i != s && i != f) {
            cem += rcs(i, s, mp);
            cem = cem % MOD;
        }
    }
    cout << cem << '\n';
}
signed main() {
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
}

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

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:95:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:96:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |     freopen("output.txt","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...