Submission #62123

#TimeUsernameProblemLanguageResultExecution timeMemory
62123bazsi700Kangaroo (CEOI16_kangaroo)C++14
6 / 100
2058 ms560 KiB
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define ll long long int #define vi vector<int> #define vii vector< vector<int> > #define PI 3.1415926535897932384626433832795 #define INF 9223372036854775807LL ll ways[10]; bool used[10]; int n,s,f; int solve(int pos, int did, int from) { if(did == n && pos == f) { return 1; } used[pos] = true; int ans = 0; if(from == -1) { for(int i = 1; i <= n; i++) { if(i != pos) { ans+= solve(i,did+1,(i < pos ? 1 : 0)); } } } else if(from == 0) { for(int i = 1; i < pos; i++) { if(!used[i]) { ans+= solve(i,did+1,1); } } } else { for(int i = pos+1; i <= n; i++) { if(!used[i]) { ans+= solve(i,did+1,0); } } } used[pos] = false; return ans; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> s >> f; if(s > f) { swap(s,f); } cout << solve(s,1,-1); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...