제출 #698865

#제출 시각아이디문제언어결과실행 시간메모리
698865dattranxxx캥거루 (CEOI16_kangaroo)C++11
6 / 100
1 ms1748 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 505;
int A[N][N][N], D[N][N][N];

int n, s, t;

int main() {
  cin.tie(0)->sync_with_stdio(0); cout.tie(0);
  cin >> n >> s >> t; 
  if (s > t) swap(s, t);
  
  A[2][1][2] = D[2][2][1] = 1;
  for (int i = 3; i <= n; ++i) {
    for (int s = 1; s <= i; ++s) {
      for (int t = i; t; --t) {
        
        if (s == t) continue;
        if (s > t) {
          A[i][s][t] = A[i][t][s];
          D[i][s][t] = D[i][t][s];
          continue;
        }
        
        for (int j = s; j <= i - 1; ++j) {
          A[i][s][t] += D[i - 1][j][t - 1];
        }
        
        for (int j = 1; j < s; ++j) {
          D[i][s][t] += A[i - 1][j][t - 1];
        }
        
        // cerr << i << ' ' << s << ' ' << t << ' ' << A[i][s][t] << ' ' << D[i][s][t] << '\n';
        
      }
    }
  }
  
  cout << A[n][s][t] + D[n][s][t];

	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...