Submission #410244

#TimeUsernameProblemLanguageResultExecution timeMemory
410244BlagojceKangaroo (CEOI16_kangaroo)C++11
6 / 100
2051 ms204 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define st first #define nd second #define all(v) begin(v), end(v) #define pq priority_queue #define pb push_back using namespace std; typedef long long ll; typedef pair<int,int> pii; const ll inf = 1e18; const ll mod = 1e9+7; const int mxn = 2e5; int n, f, s; int p = 0; vector<int> POS; int g(int a, int b, int pos, int side){ int dir = ((a+b)&1)^p; int ret = 0; if(side == 0){ if(dir == 0){ if(b == 0 && a == 1){ return 0; } fr(ipos, 0, pos){ POS.pb(ipos+1); ret += g(a-1, b, ipos, 0); POS.pop_back(); } } else{ if(b == 0 && a == 1){ return 1; } fr(ipos, pos, a-1){ POS.pb(ipos+1); ret += g(a-1, b, ipos, 0); POS.pop_back(); } fr(ipos, 0, b){ POS.pb(-ipos-1); ret += g(a-1, b, ipos, 1); POS.pop_back(); } } } else{ if(dir == 1){ if(a == 0 && b == 1){ return 0; } fr(ipos, pos, b-1){ POS.pb(-ipos-1); ret += g(a, b-1, ipos, 1); POS.pop_back(); } } else{ if(a == 0 && b == 1){ return 1; } fr(ipos, 0, pos){ POS.pb(-ipos-1); ret += g(a, b-1, ipos, 1); POS.pop_back(); } fr(ipos, 0, a){ POS.pb(ipos+1); ret += g(a, b-1, ipos, 0); POS.pop_back(); } } } return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> s >> f; if(s > f) swap(s, f); --s, --f; int A = f; int B = n-A-1; int tot = g(A, B, s, 0); p = 1; tot += g(A, B, s, 0); cout<<tot<<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...