제출 #1117644

#제출 시각아이디문제언어결과실행 시간메모리
1117644vjudge1캥거루 (CEOI16_kangaroo)C++17
6 / 100
2066 ms336 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld double const int INF = 1e18; const int mod = 12345; const int sz = 1e6 + 5; bool is_valid(vector < int > cl , int n) { int cnt = 0; if(cl[0] > cl[1]) cnt = 1; else cnt = 2; for(int i = 2;i < n;i++) { if(cnt & 1){ if(cl[i] < cl[i - 1]) return false; } else{ if(cl[i] > cl[i - 1]) return false; } cnt++; } return true; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n , s , f; cin >> n >> s >> f; vector < int > cl; for(int i = 1;i <= n;i++){ cl.push_back(i); } int ans = 0; while(next_permutation(cl.begin() , cl.end())) { if(!(cl[0] == s && cl[n - 1] == f)) continue; if(is_valid(cl , n)) { ans++; } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...