Submission #1117862

#TimeUsernameProblemLanguageResultExecution timeMemory
1117862vjudge1Kangaroo (CEOI16_kangaroo)C++17
6 / 100
2045 ms336 KiB
#pragma GCC optimize ("O3") #include<bits/stdc++.h> #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define all(v) v.begin(), v.end() #define pb push_back #define iospeed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; int main() { iospeed ll n, cs, cf, i; cin >> n >> cs >> cf; vl v; for(i = 1; i <= n; i++) v.pb(i); ll res = 0; do{ if(v[0] != cs || v.back() != cf) continue; ll lst = 1; if(v[1] < v[0]) lst = 0; bool ok = true; for(i = 2; i < n; i++) { if((v[i] > v[i-1] && lst) || (v[i] < v[i-1] && !lst)){ ok = false; break; } lst = 1 - lst; } if(ok) res++; }while(next_permutation(all(v))); cout << res << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...