제출 #893609

#제출 시각아이디문제언어결과실행 시간메모리
893609vjudge1캥거루 (CEOI16_kangaroo)C++17
6 / 100
2057 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() const int N = (int)2e5 + 5; const int MAX = (int)1e9 + 5; const ll mod = (int)1e9 + 7; const ll inf = (int)(1e9) + 100; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } void solve() { int n; cin >> n; int cs, cf; cin >> cs >> cf; vector<int> p; for (int i = 1; i <= n; i++) { p.pb(i); } int ans = 0; do { if (p[0] != cs) continue; if (p.back() != cf) continue; bool bad = 0; for (int i = 1; i < sz(p) - 1; i++) { if (!((p[i] > p[i - 1] && p[i] > p[i + 1]) || (p[i] < p[i - 1] && p[i] < p[i + 1]))) { bad = 1; break; } } ans += !bad; ans %= mod; } while (next_permutation(all(p))); cout << ans; } signed main() { //setIO("kangaroo"); ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int T = 1; //cin >> T; while (T--) solve(); return 0; }

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

kangaroo.cpp: In function 'void setIO(std::string)':
kangaroo.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen((s + ".out").c_str(), "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...